diff --git a/MuonSpectrometer/Amdcsimrec/AmdcStand/AmdcStand/amdcsim_com.inc b/MuonSpectrometer/Amdcsimrec/AmdcStand/AmdcStand/amdcsim_com.inc index d6b6aca8a7927b25e22c8b2d88b81ae2ef8c1315..3b9752752ac5a4222b550de5c9750030214546c4 100755 --- a/MuonSpectrometer/Amdcsimrec/AmdcStand/AmdcStand/amdcsim_com.inc +++ b/MuonSpectrometer/Amdcsimrec/AmdcStand/AmdcStand/amdcsim_com.inc @@ -63,7 +63,7 @@ & INOCUT(MTYP,MGEO,4), & & NOBCUT(MCUT), IOBCUT(MCUT,MOCU) !---------------------------- - INTEGER, PARAMETER :: MSTA=30 + INTEGER, PARAMETER :: MSTA=40 REAL(8) :: STAX0,STAPP,STARR,STAEE,STAPG,STATT,STAOO INTEGER :: NLAZ,NLAS,ISTAMA,IFORMA,IVALIDSTA COMMON/AMDCCHASTA/ & diff --git a/MuonSpectrometer/MuonCnv/MuonCSC_CnvTools/src/CscRdoToCscPrepDataToolCore.h b/MuonSpectrometer/MuonCnv/MuonCSC_CnvTools/src/CscRdoToCscPrepDataToolCore.h index fcbf3f86d9fec04268053696946efa00b7551b39..e7e4be4887922a5dc0891ea93d1cfab86210f58f 100644 --- a/MuonSpectrometer/MuonCnv/MuonCSC_CnvTools/src/CscRdoToCscPrepDataToolCore.h +++ b/MuonSpectrometer/MuonCnv/MuonCSC_CnvTools/src/CscRdoToCscPrepDataToolCore.h @@ -63,9 +63,9 @@ namespace Muon { protected: /// private method for the decoding RDO --> PrepRawData - StatusCode decode(const CscRawDataContainer* rdo, IdentifierHash givenIdh, + virtual StatusCode decode(const CscRawDataContainer* rdo, IdentifierHash givenIdh, std::vector<IdentifierHash>& decodedIdhs); - StatusCode decode(const CscRawDataContainer* rdo, + virtual StatusCode decode(const CscRawDataContainer* rdo, std::vector<IdentifierHash>& decodedIdhs); virtual StatusCode decode( const std::vector<uint32_t>& ) {return StatusCode::FAILURE;} diff --git a/MuonSpectrometer/MuonCnv/MuonCSC_CnvTools/src/CscRdoToCscPrepDataToolMT.cxx b/MuonSpectrometer/MuonCnv/MuonCSC_CnvTools/src/CscRdoToCscPrepDataToolMT.cxx index eda8f1c5fc9655d9e950df5c03dfc2c3edab8932..f570bfbe7826b0fe06eb0666735c1baf39d6c236 100644 --- a/MuonSpectrometer/MuonCnv/MuonCSC_CnvTools/src/CscRdoToCscPrepDataToolMT.cxx +++ b/MuonSpectrometer/MuonCnv/MuonCSC_CnvTools/src/CscRdoToCscPrepDataToolMT.cxx @@ -32,6 +32,7 @@ using namespace Muon; CscRdoToCscPrepDataToolMT::CscRdoToCscPrepDataToolMT (const std::string& type, const std::string& name, const IInterface* parent) : CscRdoToCscPrepDataToolCore(type, name, parent) { + declareProperty("CscStripPrdContainerCacheKey", m_prdContainerCacheKey, "Optional external cache for the CSC RDO container"); } CscRdoToCscPrepDataToolMT::~CscRdoToCscPrepDataToolMT(){} @@ -39,6 +40,7 @@ CscRdoToCscPrepDataToolMT::~CscRdoToCscPrepDataToolMT(){} StatusCode CscRdoToCscPrepDataToolMT::initialize(){ ATH_MSG_VERBOSE("Starting init"); ATH_CHECK( CscRdoToCscPrepDataToolCore::initialize() ); + ATH_CHECK( m_prdContainerCacheKey.initialize( !m_prdContainerCacheKey.key().empty() ) ); ATH_MSG_DEBUG("initialize() successful in " << name()); return StatusCode::SUCCESS; } @@ -56,16 +58,39 @@ StatusCode CscRdoToCscPrepDataToolMT::decode(std::vector<IdentifierHash>& givenI // clear output vector of selected data collections containing data decodedIdhs.clear(); - /// record the container in storeGate + /// Recording the PRD container in StoreGate SG::WriteHandle< Muon::CscStripPrepDataContainer > outputHandle (m_outputCollectionKey); - StatusCode status = outputHandle.record(std::make_unique<Muon::CscStripPrepDataContainer>(m_muonMgr->cscIdHelper()->module_hash_max())); - if (status.isFailure() || !outputHandle.isValid() ) { - ATH_MSG_FATAL("Could not record container of CSC PrepData Container at " << m_outputCollectionKey.key()); - return StatusCode::FAILURE; + // Caching of PRD container + const bool externalCachePRD = !m_prdContainerCacheKey.key().empty(); + if (!externalCachePRD) { + // without the cache we just record the container + StatusCode status = outputHandle.record(std::make_unique<Muon::CscStripPrepDataContainer>(m_muonMgr->cscIdHelper()->module_hash_max())); + if (status.isFailure() || !outputHandle.isValid() ) { + ATH_MSG_FATAL("Could not record container of CSC PrepData Container at " << m_outputCollectionKey.key()); + return StatusCode::FAILURE; + } + ATH_MSG_DEBUG("Created container " << m_outputCollectionKey.key()); } + else { + // use the cache to get the container + SG::UpdateHandle<CscStripPrepDataCollection_Cache> update(m_prdContainerCacheKey); + if (!update.isValid()){ + ATH_MSG_FATAL("Invalid UpdateHandle " << m_prdContainerCacheKey.key()); + return StatusCode::FAILURE; + } + StatusCode status = outputHandle.record(std::make_unique<Muon::CscStripPrepDataContainer>(update.ptr())); + if (status.isFailure() || !outputHandle.isValid() ) { + ATH_MSG_FATAL("Could not record container of CSC PrepData Container using cache " + << m_prdContainerCacheKey.key() << " - " <<m_outputCollectionKey.key()); + return StatusCode::FAILURE; + } + ATH_MSG_DEBUG("Created container using cache for " << m_prdContainerCacheKey.key()); + } + // Pass the container from the handle m_outputCollection = outputHandle.ptr(); + if (sizeVectorRequested == 0) { m_fullEventDone=true; ATH_MSG_DEBUG ( "decoding the entire event " ); @@ -91,14 +116,14 @@ StatusCode CscRdoToCscPrepDataToolMT::decode(std::vector<IdentifierHash>& givenI if (sizeVectorRequested) { // seeded decoding for (unsigned int i=0; i<sizeVectorRequested; ++i) { - if (decode(rdoContainer, givenIdhs[i],decodedIdhs).isFailure()) { + if (CscRdoToCscPrepDataToolMT::decode(rdoContainer, givenIdhs[i],decodedIdhs).isFailure()) { ATH_MSG_ERROR ( "Unable to decode CSC RDO " << i << "th into CSC PrepRawData" ); return StatusCode::FAILURE; } } } else { // unseeded decoding - if (decode(rdoContainer, decodedIdhs).isFailure()) { + if (CscRdoToCscPrepDataToolMT::decode(rdoContainer, decodedIdhs).isFailure()) { ATH_MSG_ERROR ( "Unable to decode CSC RDO " ); return StatusCode::FAILURE; } @@ -106,3 +131,376 @@ StatusCode CscRdoToCscPrepDataToolMT::decode(std::vector<IdentifierHash>& givenI return StatusCode::SUCCESS; } + +StatusCode CscRdoToCscPrepDataToolMT::decode(const CscRawDataContainer* rdoContainer, IdentifierHash givenHashId, std::vector<IdentifierHash>& decodedIdhs) { + + + IdContext cscContext = m_muonIdHelperTool->cscIdHelper().module_context(); + + // if CSC decoding is switched off stop here + if( !m_decodeData ) { + ATH_MSG_DEBUG ( "Stored empty container; Decoding CSC RDO into CSC PrepRawData is switched off" ); + return StatusCode::SUCCESS; + } + + //These collections can be empty for the trigger + if(!m_outputCollection || m_outputCollection->size()==0){ + ATH_MSG_DEBUG("Stored empty collection."); + return StatusCode::SUCCESS; + } + + ATH_MSG_DEBUG ( "Decoding CSC RDO into CSC PrepRawData" ); + /// create the CSC RDO decoder + //********************************************** + // retrieve specific collection for the givenID + uint16_t idColl = 0xffff; + m_cabling->hash2CollectionId(givenHashId,idColl); + CscRawDataContainer::const_iterator it_coll = rdoContainer->indexFind(idColl); + if (rdoContainer->end() == it_coll) { + ATH_MSG_DEBUG ( "Specific CSC RDO collection retrieving failed for collection hash = " << idColl ); + return StatusCode::SUCCESS; + } + + const CscRawDataCollection * rawCollection = *it_coll; + ATH_MSG_DEBUG ( "Retrieved " << rawCollection->size() << " CSC RDOs."); + //************************************************ + IdentifierHash cscHashId; + + unsigned int samplingTime = rawCollection->rate(); + unsigned int numSamples = rawCollection->numSamples(); + bool samplingPhase = rawCollection->samplingPhase(); + std::vector<float> charges; + charges.reserve(4); + std::vector<uint16_t> samples; + samples.reserve(4); + + if ( int(samplingTime) != int(m_cscCalibTool->getSamplingTime())) { + ATH_MSG_WARNING ( " CSC sampling time from Collection is NOT consistant to calibTool parameter!!!!!!! " ); + } + + // For each Rdo, loop over RawData, converter RawData to PrepRawData + // Retrieve/create PrepRawData collection, and insert PrepRawData into collection + CscRawDataCollection::const_iterator itD = rawCollection->begin(); + CscRawDataCollection::const_iterator itD_e = rawCollection->end(); + + // Each RDO Collection goes into a PRD Collection, but we need to know what hash the PRD container is + // and this is determined by the stationID, no the RDO hash ID + ATH_MSG_DEBUG("CSC RDO ID " << rawCollection->identify() << " with hashID " << rawCollection->identifyHash() ); + // Just use the first iterator entry as stationID does not change between data inside a single container + Identifier stationId = m_cscRdoDecoderTool->stationIdentifier( (const CscRawData *)(*itD) ); + if (m_muonIdHelperTool->cscIdHelper().get_hash(stationId, cscHashId, &cscContext)) { + ATH_MSG_WARNING ( "Unable to get CSC digiti collection hash id " + << "context begin_index = " << cscContext.begin_index() + << " context end_index = " << cscContext.end_index() + << " the identifier is " ); + stationId.show(); + } + ATH_MSG_DEBUG("Create CSC PRD Collection with hash " << cscHashId << " (givenHashId is " << givenHashId << ")"); + std::unique_ptr<CscStripPrepDataCollection> collection = nullptr; + CscStripPrepDataContainer::IDC_WriteHandle lock = m_outputCollection->getWriteHandle( cscHashId ); + // Note that if the hash check above works, we should never reach this step where the lock is present + if( lock.alreadyPresent() ) { + ATH_MSG_DEBUG ( "CSC PRD collection already exist with collection hash = " << cscHashId << " collection filling is skipped!"); + decodedIdhs.push_back(givenHashId); + return StatusCode::SUCCESS; + } + else{ + ATH_MSG_DEBUG ( "CSC PRD collection does not exist - creating a new one with hash = " << cscHashId ); + collection = std::make_unique<CscStripPrepDataCollection>( cscHashId ); + collection->setIdentifier(stationId); + } + + for (; itD!=itD_e; ++itD) { + const CscRawData * data = (*itD); + uint16_t width = data->width(); + uint16_t totalSamples = (data->samples()).size(); + uint32_t hashOffset = data->hashId(); + + ATH_MSG_DEBUG ( " Size of online cluster in this RawData: " + << " Width = " << width << " Samples = " << totalSamples + << " stationId : " << stationId << " hashOffset : " << hashOffset); + + for (unsigned int j=0; j<width; ++j) { + const Identifier channelId = m_cscRdoDecoderTool->channelIdentifier(data, j); + ATH_MSG_DEBUG ( " LOOP over width " << j << " " << channelId ); + + const CscReadoutElement * descriptor = m_muonMgr->getCscReadoutElement(channelId); + //calculate local positions on the strip planes + if ( !descriptor ) { + ATH_MSG_WARNING ( "Invalid descriptor for " << m_muonIdHelperTool->cscIdHelper().show_to_string(channelId) + << " Skipping channel " ); + continue; + } else if (!descriptor->containsId(channelId)) { + ATH_MSG_WARNING ("Identifier from the cabling service <" + <<m_muonIdHelperTool->cscIdHelper().show_to_string(channelId) + <<"> inconsistent with the geometry of detector element <" + <<m_muonIdHelperTool->cscIdHelper().show_to_string(descriptor->identify()) + <<"> =>>ignore this hit"); + continue; + } + + float timeOfFirstSample = 0.0; + bool extractSamples = data->samples(j, numSamples, samples); + if (!extractSamples) { + ATH_MSG_WARNING ( "Unable to extract samples for strip " << j + << " Online Cluster width = " << width + << " for number of Samples = " << numSamples + << " continuing ..." ); + continue; + } + + IdentifierHash stripHash; + if (m_muonIdHelperTool->cscIdHelper().get_channel_hash(channelId, stripHash)) { + ATH_MSG_WARNING ( "Unable to get CSC strip hash id"); + channelId.show(); + } + + bool adctocharge = m_cscCalibTool->adcToCharge(samples, stripHash, charges); + if ( !adctocharge ) { + ATH_MSG_WARNING ( " CSC conversion ADC to Charge failed " + << "CSC PrepData not build ... skipping " ); + continue; + } + if ( samples.size() >=4 ) + ATH_MSG_DEBUG ( "ADC: " << m_muonIdHelperTool->cscIdHelper().show_to_string(channelId) + << " " << samples[0] << " " << samples[1] << " " << samples[2] << " " << samples[3] + << " Charges: " + << " " << charges[0] << " " << charges[1] << " " << charges[2] << " " << charges[3] ); + + int measuresPhi = m_muonIdHelperTool->cscIdHelper().measuresPhi(channelId); + + Amg::Vector2D localWirePos1( descriptor->xCoordinateInTrackingFrame(channelId ),0.); + + int chamberLayer = m_muonIdHelperTool->cscIdHelper().chamberLayer(channelId); + float stripWidth = descriptor->cathodeReadoutPitch( chamberLayer, measuresPhi ); + double errPos = stripWidth / sqrt(12.0); + + AmgSymMatrix(2) covariance; + covariance.setIdentity(); + covariance *= errPos*errPos; + Amg::MatrixX * errClusterPos = new Amg::MatrixX(covariance); + + /** new CscStripPrepRawData */ + CscStripPrepData * newPrepData = new CscStripPrepData(channelId, + cscHashId, + localWirePos1, + errClusterPos, + descriptor, + charges, + timeOfFirstSample, + samplingTime); + + if (samplingPhase) newPrepData->set_samplingPhase(); + newPrepData->setHashAndIndex(collection->identifyHash(), collection->size()); + collection->push_back(newPrepData); + + } + } + // Record the container + StatusCode status_lock = lock.addOrDelete(std::move( collection ) ); + if (status_lock.isFailure()) { + ATH_MSG_ERROR ( "Could not insert CscStripPrepdataCollection into CscStripPrepdataContainer..." ); + return StatusCode::FAILURE; + } + else{ + decodedIdhs.push_back(cscHashId); + } + return StatusCode::SUCCESS; +} + +//************** Process for all in case of Offline +StatusCode CscRdoToCscPrepDataToolMT::decode(const CscRawDataContainer* rdoContainer, std::vector<IdentifierHash>& decodedIdhs) +{ + + typedef CscRawDataContainer::const_iterator collection_iterator; + + IdContext cscContext = m_muonIdHelperTool->cscIdHelper().module_context(); + + // if CSC decoding is switched off stop here + if( !m_decodeData ) { + ATH_MSG_DEBUG ( "Stored empty container. " + << "Decoding CSC RDO into CSC PrepRawData is switched off" ); + return StatusCode::SUCCESS; + } + ATH_MSG_DEBUG ( "Decoding CSC RDO into CSC PrepRawData" ); + + collection_iterator rdoColl = rdoContainer->begin(); + collection_iterator lastRdoColl = rdoContainer->end(); + std::vector<float> charges; + charges.reserve(4); + std::vector<uint16_t> samples; + samples.reserve(4); + + Identifier oldId; + IdentifierHash cscHashId; + Identifier stationId; + for (; rdoColl!=lastRdoColl; ++rdoColl) { + if ( (*rdoColl)->size() > 0 ) { + ATH_MSG_DEBUG ( " Number of RawData in this rdo " << (*rdoColl)->size() ); + + const CscRawDataCollection* cscCollection = *rdoColl; + unsigned int samplingTime = cscCollection->rate(); + unsigned int numSamples = cscCollection->numSamples(); + bool samplingPhase = cscCollection->samplingPhase(); + + if ( int(samplingTime) != int(m_cscCalibTool->getSamplingTime())) { + ATH_MSG_WARNING ( " CSC sampling time from Collection is NOT consistant to calibTool parameter!!!!!!! " ); + } + // For each Rdo, loop over RawData, converter RawData to PrepRawData + // Retrieve/create PrepRawData collection, and insert PrepRawData into collection + CscRawDataCollection::const_iterator itD = cscCollection->begin(); + CscRawDataCollection::const_iterator itD_e = cscCollection->end(); + + // Each RDO Collection goes into a PRD Collection, but we need to know what hash the PRD container is + // and this is determined by the stationID, no the RDO hash ID + ATH_MSG_DEBUG("CSC RDO ID " << (*rdoColl)->identify() << " with hashID " << (*rdoColl)->identifyHash() ); + // Just use the first iterator entry as stationID does not change between data inside a single container + Identifier stationId = m_cscRdoDecoderTool->stationIdentifier( (const CscRawData *)(*itD) ); + if (m_muonIdHelperTool->cscIdHelper().get_hash(stationId, cscHashId, &cscContext)) { + ATH_MSG_WARNING ( "Unable to get CSC digiti collection hash id " + << "context begin_index = " << cscContext.begin_index() + << " context end_index = " << cscContext.end_index() + << " the identifier is " ); + stationId.show(); + } + + ATH_MSG_DEBUG("Create CSC PRD Collection with hash " << cscHashId); + std::unique_ptr<CscStripPrepDataCollection> collection = nullptr; + CscStripPrepDataContainer::IDC_WriteHandle lock = m_outputCollection->getWriteHandle( cscHashId ); + if( lock.alreadyPresent() ) { + ATH_MSG_DEBUG ( "CSC PRD collection already exist with collection hash = " << cscHashId << " collection filling is skipped!"); + continue; + } + else{ + ATH_MSG_DEBUG ( "CSC PRD collection does not exist - creating a new one with hash = " << cscHashId ); + collection = std::make_unique<CscStripPrepDataCollection>( cscHashId ); + collection->setIdentifier(stationId); + } + + // This loops over the RDO data, decodes and puts into the PRD collection + for (; itD!=itD_e; ++itD) { + const CscRawData * data = (*itD); + uint16_t width = data->width(); + uint16_t totalSamples = (data->samples()).size(); + uint32_t hashOffset = data->hashId(); + + ATH_MSG_DEBUG ( "DecodeAll*Size of online cluster in this RawData: " + << " Width = " << width << " Samples = " << totalSamples + << " stationId : " << stationId << " hashOffset : " << hashOffset); + + for (unsigned int j=0; j<width; ++j) { + const Identifier channelId = m_cscRdoDecoderTool->channelIdentifier(data, j); + ATH_MSG_DEBUG ( "DecodeAll**LOOP over width " << j << " " << channelId ); + + const CscReadoutElement * descriptor = m_muonMgr->getCscReadoutElement(channelId); + //calculate local positions on the strip planes + if ( !descriptor ) { + ATH_MSG_WARNING ( "Invalid descriptor for " << m_muonIdHelperTool->cscIdHelper().show_to_string(channelId) + << " Skipping channel " ); + continue; + } + else if (!descriptor->containsId(channelId)) { + ATH_MSG_WARNING ("Identifier from the cabling service <" + <<m_muonIdHelperTool->cscIdHelper().show_to_string(channelId) + <<"> inconsistent with the geometry of detector element <" + <<m_muonIdHelperTool->cscIdHelper().show_to_string(descriptor->identify()) + <<"> =>>ignore this hit"); + continue; + } + + float timeOfFirstSample = 0.0; + bool extractSamples = data->samples(j, numSamples, samples); + if (!extractSamples) { + ATH_MSG_WARNING ( "Unable to extract samples for strip " << j + << " Online Cluster width = " << width + << " for number of Samples = " << numSamples + << " continuing ..." ); + continue; + } + + IdentifierHash stripHash; + if (m_muonIdHelperTool->cscIdHelper().get_channel_hash(channelId, stripHash)) { + ATH_MSG_WARNING ( "Unable to get CSC strip hash id"); + channelId.show(); + } + + + Identifier channelIdFromHash; + m_muonIdHelperTool->cscIdHelper().get_id(stripHash, channelIdFromHash, &cscContext); + + + bool adctocharge = m_cscCalibTool->adcToCharge(samples, stripHash, charges); + if ( !adctocharge ) { + ATH_MSG_WARNING ( " CSC conversion ADC to Charge failed " + << "CSC PrepData not build ... skipping " ); + continue; + } + if ( samples.size() >=4 ) + ATH_MSG_DEBUG ( "DecodeAll*** ADC: " << m_muonIdHelperTool->cscIdHelper().show_to_string(channelId) << " " + << (int) stripHash << " " + << m_muonIdHelperTool->cscIdHelper().show_to_string(channelIdFromHash) + << " " << samples[0] << " " << samples[1] << " " << samples[2] << " " << samples[3] + << " Charges: " + << " " << charges[0] << " " << charges[1] << " " << charges[2] << " " << charges[3] ); + if (m_muonIdHelperTool->cscIdHelper().get_hash(stationId, cscHashId, &cscContext)) { + ATH_MSG_WARNING ( "Unable to get CSC hash id from CSC RDO collection " + << "context begin_index = " << cscContext.begin_index() + << " context end_index = " << cscContext.end_index() + << " the identifier is " ); + stationId.show(); + } + + // Check if this strip is already decoded.. Then we don't have to decode it again + bool IsThisStripDecoded =0; + for ( CscStripPrepDataCollection::const_iterator idig=collection->begin(); + idig!=collection->end(); ++idig ) { + const CscStripPrepData& dig = **idig; + Identifier did = dig.identify(); + if (did ==channelId) { + IsThisStripDecoded =1; + break; + } + } + if (IsThisStripDecoded) continue; + + int measuresPhi = m_muonIdHelperTool->cscIdHelper().measuresPhi(channelId); + + Amg::Vector2D localWirePos1( descriptor->xCoordinateInTrackingFrame(channelId ),0.); + + + int chamberLayer = m_muonIdHelperTool->cscIdHelper().chamberLayer(channelId); + float stripWidth = descriptor->cathodeReadoutPitch( chamberLayer, measuresPhi ); + double errPos = stripWidth / sqrt(12.0); + + AmgSymMatrix(2) covariance; + covariance.setIdentity(); + covariance *= errPos*errPos; + Amg::MatrixX * errClusterPos = new Amg::MatrixX(covariance); + + /** new CscPrepRawData */ + CscStripPrepData * newPrepData = new CscStripPrepData( channelId, + cscHashId, + localWirePos1, + errClusterPos, + descriptor, + charges, + timeOfFirstSample, + samplingTime); + + if (samplingPhase) newPrepData->set_samplingPhase(); + newPrepData->setHashAndIndex(collection->identifyHash(), collection->size()); + collection->push_back(newPrepData); + + } + } + // Record the container after looping through all the RDO data in this RDO collection + StatusCode status_lock = lock.addOrDelete(std::move( collection ) ); + if (status_lock.isFailure()) { + ATH_MSG_ERROR ( "Could not insert CscStripPrepdataCollection into CscStripPrepdataContainer..." ); + return StatusCode::FAILURE; + } + decodedIdhs.push_back(cscHashId); + } + } + return StatusCode::SUCCESS; +} \ No newline at end of file diff --git a/MuonSpectrometer/MuonCnv/MuonCSC_CnvTools/src/CscRdoToCscPrepDataToolMT.h b/MuonSpectrometer/MuonCnv/MuonCSC_CnvTools/src/CscRdoToCscPrepDataToolMT.h index 88c4ba2e7b4ae79ad104332d942c28752c500d69..aacbf864131ce7eb712b55cf7b449dba699b6079 100644 --- a/MuonSpectrometer/MuonCnv/MuonCSC_CnvTools/src/CscRdoToCscPrepDataToolMT.h +++ b/MuonSpectrometer/MuonCnv/MuonCSC_CnvTools/src/CscRdoToCscPrepDataToolMT.h @@ -6,6 +6,7 @@ #define MUONCSC_CNVTOOLS_CSCRDOTOCSCPREPDATATOOLMT_H #include "CscRdoToCscPrepDataToolCore.h" +#include "MuonPrepRawData/MuonPrepDataCollection_Cache.h" #include <string> @@ -40,6 +41,14 @@ namespace Muon { using CscRdoToCscPrepDataToolCore::decode; virtual StatusCode decode(std::vector<IdentifierHash>& givenIdhs, std::vector<IdentifierHash>& decodedIdhs) override; + virtual StatusCode decode(const CscRawDataContainer* rdoContainer, IdentifierHash givenHashId, std::vector<IdentifierHash>& decodedIdhs) override; + virtual StatusCode decode(const CscRawDataContainer* rdoContainer, std::vector<IdentifierHash>& decodedIdhs) override; + + + + private: + /// This is the key for the cache for the CSC PRD containers, can be empty + SG::UpdateHandleKey<CscStripPrepDataCollection_Cache> m_prdContainerCacheKey ; }; } #endif /// MUONCSC_CNVTOOL_CSCRDOTOCSCPREPDATA_H diff --git a/MuonSpectrometer/MuonCnv/MuonMDT_CnvTools/src/MdtRdoToPrepDataToolCore.cxx b/MuonSpectrometer/MuonCnv/MuonMDT_CnvTools/src/MdtRdoToPrepDataToolCore.cxx index c384bb51b6a9b2e0d35e7ba355e14be678e86579..45340a3ee88ba1da65b75512dc40adc77568abe0 100644 --- a/MuonSpectrometer/MuonCnv/MuonMDT_CnvTools/src/MdtRdoToPrepDataToolCore.cxx +++ b/MuonSpectrometer/MuonCnv/MuonMDT_CnvTools/src/MdtRdoToPrepDataToolCore.cxx @@ -54,7 +54,6 @@ Muon::MdtRdoToPrepDataToolCore::MdtRdoToPrepDataToolCore(const std::string& t, // template for property decalration declareProperty("CalibratePrepData", m_calibratePrepData = true ); declareProperty("DecodeData", m_decodeData = true ); - declareProperty("SortPrepData", m_sortPrepData = false ); // + TWIN TUBE declareProperty("UseTwin", m_useTwin = true); @@ -224,69 +223,79 @@ void Muon::MdtRdoToPrepDataToolCore::processRDOContainer( std::vector<Identifier const MdtCsmContainer* rdoContainer = getRdoContainer(); if(!rdoContainer) { return; - } - // unseeded mode - for (MdtCsmContainer::const_iterator rdoColli = rdoContainer->begin(); rdoColli!=rdoContainer->end(); ++rdoColli) { - - auto rdoColl = *rdoColli; - if (rdoColl->empty()) continue; - ATH_MSG_DEBUG("A new csm here with " << rdoColl->size() <<" amt hits inside "); - if(processCsm(rdoColl, idWithDataVect).isFailure()) { - ATH_MSG_DEBUG("processCsm returns a bad StatusCode - keep going for new data collections in this event"); - } - } - // finally sort the collections - if (m_sortPrepData) { - for( auto it = m_mdtPrepDataContainer->begin();it != m_mdtPrepDataContainer->end(); ++it) { - sortMdtPrdCollection(*it); - } - } -} + } -void Muon::MdtRdoToPrepDataToolCore::sortMdtPrdCollection( const Muon::MdtPrepDataCollection* col ){ - // this method is using nasty const_casts - we should get rid of them if possible - if(!col) return; - const_cast<Muon::MdtPrepDataCollection*>(col)->sort([]( const Muon::MdtPrepData* prd1, const Muon::MdtPrepData* prd2 ) { - return prd1->identify() < prd2->identify(); - }); - // need to modify indices saved within the sorted PrepData objects - for (unsigned short index=0; index < col->size(); ++index) { - const_cast<IdentContIndex*>( &(col->at(index)->getHashAndIndex()) )->setObjIndex(index); + // It is more practical to loop through all the hashes rather than all RDO elements + // as we benefit from handling the 2 RDO to 1 PRD special case + for(unsigned int iHash = 0; iHash < m_muonIdHelperTool->mdtIdHelper().module_hash_max(); iHash++){ + handlePRDHash( IdentifierHash(iHash), *rdoContainer, idWithDataVect); } + //for (MdtCsmContainer::const_iterator rdoColli = rdoContainer->begin(); rdoColli!=rdoContainer->end(); ++rdoColli) { +// + // handlePRDHash( (*rdoColli)->identifyHash(), *rdoContainer, idWithDataVect); + //} + } bool Muon::MdtRdoToPrepDataToolCore::handlePRDHash( IdentifierHash hash, const MdtCsmContainer& rdoContainer, std::vector<IdentifierHash>& idWithDataVect ) { - // if in prep data the chamber already exists ... do nothing - if( m_mdtPrepDataContainer->indexFind(hash) != m_mdtPrepDataContainer->end() ){ + // Check PRD container for the hash, if it exists, we already decoded fully + if( m_mdtPrepDataContainer->tryAddFromCache(hash) ){ + ATH_MSG_DEBUG("RDO hash " << hash << " already decoded and inside PRD container cache"); return true; } + IdentifierHash rdoHash = hash; // before BMEs were installed, RDOs were indexed by offline hashes (same as PRD) if (m_BMEpresent) { // after BMEs were installed, the RDOs are indexed by the detectorElement hash of a multilayer Identifier elementId; IdContext tmp_context = m_muonIdHelperTool->mdtIdHelper().module_context(); m_muonIdHelperTool->mdtIdHelper().get_id(hash, elementId, &tmp_context); + Identifier multilayerId = m_muonIdHelperTool->mdtIdHelper().multilayerID(elementId, 1); //first multilayer IdentifierHash multilayerHash; m_muonIdHelperTool->mdtIdHelper().get_detectorElement_hash(multilayerId, multilayerHash); rdoHash = multilayerHash; - - // process CSM if data was found - MdtCsmContainer::const_iterator rdoColli = rdoContainer.indexFind(rdoHash); - if( rdoColli != rdoContainer.end() ) { - if ( processCsm(*rdoColli, idWithDataVect).isFailure() ) { - ATH_MSG_WARNING("processCsm failed for RDO id " << (unsigned long long)((*rdoColli)->identify().get_compact())); - return false; - } - } else ATH_MSG_DEBUG("handlePRDHash: hash id " << (unsigned int)(hash) << " not found in RDO container"); - + // for BMEs there are 2 CSMs per chamber, registered with the hashes of the 2 multilayers - // we've processed only one now, now time for the second + // If this is BMEid then we handle two RDO at once, else just one if (m_muonIdHelperTool->mdtIdHelper().stationName(elementId) == m_BMEid) { - multilayerId = m_muonIdHelperTool->mdtIdHelper().multilayerID(elementId, 2); //second multilayer - m_muonIdHelperTool->mdtIdHelper().get_detectorElement_hash(multilayerId, multilayerHash); - rdoHash = multilayerHash; - + Identifier multilayerId2 = m_muonIdHelperTool->mdtIdHelper().multilayerID(elementId, 2); //second multilayer + IdentifierHash multilayerHash2; + m_muonIdHelperTool->mdtIdHelper().get_detectorElement_hash(multilayerId2, multilayerHash2); + IdentifierHash rdoHash2 = multilayerHash2; + // Retrieve the two RDO + MdtCsmContainer::const_iterator rdoColli = rdoContainer.indexFind(rdoHash); + MdtCsmContainer::const_iterator rdoColli2 = rdoContainer.indexFind(rdoHash2); + if( rdoColli != rdoContainer.end() && rdoColli2 != rdoContainer.end() ) { + // Handle both at once + if(processCsm(*rdoColli, idWithDataVect, *rdoColli2).isFailure()){ + ATH_MSG_WARNING("processCsm failed for RDO id " + << (unsigned long long)((*rdoColli)->identify().get_compact()) << " and " + << (unsigned long long)((*rdoColli2)->identify().get_compact())); + return false; + } + } + else if(rdoColli != rdoContainer.end()){ + // Handle just one + ATH_MSG_DEBUG("Only one RDO container was found for hash " << hash << " despite BME - Missing " << rdoHash2 ); + if ( processCsm(*rdoColli, idWithDataVect).isFailure() ) { + ATH_MSG_WARNING("processCsm failed for RDO id " << (unsigned long long)((*rdoColli)->identify().get_compact())); + return false; + } + } + else if(rdoColli2 != rdoContainer.end()){ + // Handle just one + ATH_MSG_DEBUG("Only one RDO container was found for hash " << hash << " despite BME - Missing " << rdoHash ); + if ( processCsm(*rdoColli2, idWithDataVect).isFailure() ) { + ATH_MSG_WARNING("processCsm failed for RDO id " << (unsigned long long)((*rdoColli)->identify().get_compact())); + return false; + } + } + else{ + ATH_MSG_DEBUG("handlePRDHash: hash id " << hash << " not found in RDO container, and is BME - Missing " << rdoHash << " " << rdoHash2); + } + } // End of m_BMEpresent + else{ // process CSM if data was found MdtCsmContainer::const_iterator rdoColli = rdoContainer.indexFind(rdoHash); if( rdoColli != rdoContainer.end() ) { @@ -295,8 +304,7 @@ bool Muon::MdtRdoToPrepDataToolCore::handlePRDHash( IdentifierHash hash, const M return false; } } else ATH_MSG_DEBUG("handlePRDHash: hash id " << (unsigned int)(hash) << " not found in RDO container"); - - } + } } else { // using pre-BME data // process CSM if data was found MdtCsmContainer::const_iterator rdoColli = rdoContainer.indexFind(rdoHash); @@ -307,14 +315,7 @@ bool Muon::MdtRdoToPrepDataToolCore::handlePRDHash( IdentifierHash hash, const M } } else ATH_MSG_DEBUG("handlePRDHash: hash id " << (unsigned int)(hash) << " not found in RDO container"); } - - // sort hits in the collection - if (m_sortPrepData) { - auto it = m_mdtPrepDataContainer->indexFind(hash); - if( it != m_mdtPrepDataContainer->end() ) { - sortMdtPrdCollection(*it); - } - } + return true; } @@ -457,7 +458,7 @@ void Muon::MdtRdoToPrepDataToolCore::printPrepData( ) } -StatusCode Muon::MdtRdoToPrepDataToolCore::processCsm(const MdtCsm *rdoColl, std::vector<IdentifierHash>& idWithDataVect) { +StatusCode Muon::MdtRdoToPrepDataToolCore::processCsm(const MdtCsm *rdoColl, std::vector<IdentifierHash>& idWithDataVect, const MdtCsm *rdoColl2 ) { // first handle the case of twin tubes if(m_useTwin){ @@ -473,21 +474,39 @@ StatusCode Muon::MdtRdoToPrepDataToolCore::processCsm(const MdtCsm *rdoColl, std ATH_MSG_DEBUG(" ***************** Start of processCsm"); + // Make some checks if we are in special circumstances + if(rdoColl2){ + Identifier elementId1 = m_muonIdHelperTool->mdtIdHelper().parentID(rdoColl->identify()); + Identifier elementId2 = m_muonIdHelperTool->mdtIdHelper().parentID(rdoColl2->identify()); + IdContext mdtContext = m_muonIdHelperTool->mdtIdHelper().module_context(); + IdentifierHash hash1, hash2; + m_muonIdHelperTool->mdtIdHelper().get_hash(elementId1, hash1, &mdtContext); + m_muonIdHelperTool->mdtIdHelper().get_hash(elementId2, hash2, &mdtContext); + ATH_MSG_DEBUG("Special case with 2 RDO going into 1 PRD - ID1 " << elementId1 + << " ID2 " << elementId2 << " hash 1 " << hash1 << " hash 2 " << hash2 ); + // These should have the same PRD MDT hash otherwise we need to understand why we are here + if(hash1 != hash2){ + ATH_MSG_ERROR("Hash1 and Hash2 are different for special case : " << hash1 << " " << hash2); + return StatusCode::FAILURE; + } + ATH_MSG_DEBUG(" Number of AmtHit in this Csm (1) " << rdoColl->size() <<" CSM id is "<<m_idHelper->toString(elementId1)); + ATH_MSG_DEBUG(" Number of AmtHit in this Csm (2) " << rdoColl2->size() <<" CSM id is "<<m_idHelper->toString(elementId2)); + } + /// MDT hit context //IdContext hitContext = m_muonIdHelperTool->mdtIdHelper().channel_context(); Identifier elementId = m_muonIdHelperTool->mdtIdHelper().parentID(rdoColl->identify()); - + // prepare the special case of two chamber connected to the same CSM // create objects but do not initialize them bool doubleCsmFound = false; bool doubleCsm = false; Identifier secondElementId; - MdtPrepDataCollection* secondDriftCircleColl = NULL; IdentifierHash secondMdtHashId; - ATH_MSG_DEBUG(" Number of AmtHit in this Csm " - << rdoColl->size() <<" CSM id is "<<m_idHelper->toString(elementId)); + if(!rdoColl2) + ATH_MSG_DEBUG(" Number of AmtHit in this Csm " << rdoColl->size() <<" CSM id is "<<m_idHelper->toString(elementId)); uint16_t subdetId = rdoColl->SubDetId(); uint16_t mrodId = rdoColl->MrodId(); @@ -508,34 +527,21 @@ StatusCode Muon::MdtRdoToPrepDataToolCore::processCsm(const MdtCsm *rdoColl, std } ATH_MSG_VERBOSE("HashId = "<<(int)mdtHashId); - MdtPrepDataCollection * driftCircleColl = NULL; + std::unique_ptr<MdtPrepDataCollection> driftCircleColl = nullptr; + std::unique_ptr<MdtPrepDataCollection> secondDriftCircleColl = nullptr; - if ( m_mdtPrepDataContainer->indexFind(mdtHashId) != m_mdtPrepDataContainer->end() ) { - // for elevator chambers there are 2 CSMs to be filled in the same collection - if ( m_muonIdHelperTool->mdtIdHelper().stationName(elementId) == m_BMEid && m_BMEpresent) { - driftCircleColl = const_cast<MdtPrepDataCollection*>(&(**m_mdtPrepDataContainer->indexFind(mdtHashId))); - ATH_MSG_DEBUG("In ProcessCSM - collection already contained in IDC, but BME! Taking it."); - } - else { - ATH_MSG_DEBUG("In ProcessCSM - collection already contained in IDC"); - return StatusCode::FAILURE; - } + // Check the IDC cache (no write handles here) + if( m_mdtPrepDataContainer->tryAddFromCache(mdtHashId) ){ + // The collection is in the container so we should not process anything (true for elevator chambers) + ATH_MSG_DEBUG("In ProcessCSM - collection already contained in IDC " << elementId << " " << mdtHashId); + // But instead of returning, we will process in case this RDO has two possible PRD and we only decoded one } - // create new collection + add it if there's nothing yet (also for the first CSM of a elevator chambers) - else { - driftCircleColl = new MdtPrepDataCollection(mdtHashId); + // Create new collection + else{ + driftCircleColl.reset( new MdtPrepDataCollection( mdtHashId ) ); idWithDataVect.push_back(mdtHashId); driftCircleColl->setIdentifier(elementId); - ATH_MSG_DEBUG("A new MdtPrepDataCollection here with hashId " << (unsigned int)mdtHashId); - //MdtPrepDataContainer::KEY key = m_mdtPrepDataContainer->key(elementId); - - if (StatusCode::SUCCESS != m_mdtPrepDataContainer->addCollection(driftCircleColl, mdtHashId)) { - ATH_MSG_DEBUG("In ProcessCSM - Couldn't record in the Container MDT Drift Circle Collection with hashID = " - << (int)mdtHashId <<" ext. id = " - << m_idHelper->toString(elementId)); - return StatusCode::FAILURE; - } - ATH_MSG_DEBUG("MdtPrepDataCollection added to the container"); + ATH_MSG_DEBUG("Created MdtPrepDataCollection (not found in cache) " << (unsigned int)mdtHashId); } // for each Csm, loop over AmtHit, converter AmtHit to digit @@ -543,8 +549,26 @@ StatusCode Muon::MdtRdoToPrepDataToolCore::processCsm(const MdtCsm *rdoColl, std MdtCsm::const_iterator itD = rdoColl->begin(); MdtCsm::const_iterator itD_e = rdoColl->end(); + // Note that for 2 RDO -> 1 PRD, the first RDO _can_ be empty, so we should check before we loop + if(rdoColl2){ + // Check finished the first collection (second pass is handled by for-loop end condition) + if(itD == rdoColl->end()){ + ATH_MSG_DEBUG("RDO collection 1 is empty - Iterators moving to RDO collection 2"); + // Update our iterators and continue processing + itD = rdoColl2->begin(); + itD_e = rdoColl2->end(); + + elementId = m_muonIdHelperTool->mdtIdHelper().parentID(rdoColl2->identify()); + subdetId = rdoColl2->SubDetId(); + mrodId = rdoColl2->MrodId(); + csmId = rdoColl2->CsmId(); + ATH_MSG_VERBOSE("Identifier = "<<m_idHelper->toString(elementId) + <<" subdetId/ mrodId/ csmId = "<<subdetId<<" / "<<mrodId<<" / "<<csmId); + } + } + int mc = 0; - for (; itD!=itD_e; ++itD) { + for (; itD!=itD_e; ) { mc++; const MdtAmtHit * amtHit = (*itD); @@ -562,6 +586,7 @@ StatusCode Muon::MdtRdoToPrepDataToolCore::processCsm(const MdtCsm *rdoColl, std ATH_MSG_WARNING("Found issue MDT RDO decoder for subdetId/mrodId/csmId " <<subdetId<<"/"<<mrodId<<"/"<<csmId<<" amtHit channelId/tdcId =" <<amtHit->channelId()<<"/"<<amtHit->tdcId()); + itD++; continue; } @@ -574,6 +599,7 @@ StatusCode Muon::MdtRdoToPrepDataToolCore::processCsm(const MdtCsm *rdoColl, std if( std::find( (myIt->second).begin(), (myIt->second).end(), channelId) != (myIt->second).end() ) { ATH_MSG_DEBUG("processCsm : Deleting BMG digit with identifier" << m_muonIdHelperTool->mdtIdHelper().show_to_string(channelId) ); delete newDigit; + itD++; continue; } } @@ -617,22 +643,16 @@ StatusCode Muon::MdtRdoToPrepDataToolCore::processCsm(const MdtCsm *rdoColl, std } ATH_MSG_VERBOSE("HashId = "<<(int) secondMdtHashId); - if (m_mdtPrepDataContainer->indexFind(secondMdtHashId)!=m_mdtPrepDataContainer->end()) { + // If we got to here we need to inspect the cache and create or nullptr + if( m_mdtPrepDataContainer->tryAddFromCache(secondMdtHashId) ){ ATH_MSG_DEBUG("In ProcessCSM - collection already contained in IDC"); - return StatusCode::FAILURE; + // Proceed with the nullptr } - - secondDriftCircleColl = new MdtPrepDataCollection(secondMdtHashId); - idWithDataVect.push_back(secondMdtHashId); - secondDriftCircleColl->setIdentifier(secondElementId); - - ATH_MSG_DEBUG("A new MdtPrepDataCollection here with hashId " << (unsigned int)secondMdtHashId); - - if (StatusCode::SUCCESS != m_mdtPrepDataContainer->addCollection(secondDriftCircleColl, secondMdtHashId)) { - ATH_MSG_DEBUG("In ProcessCSM - Couldn't record in the Container MDT Drift Circle Collection with hashID = " - << (int)secondMdtHashId <<" ext. id = " - << m_idHelper->toString(secondElementId)); - return StatusCode::FAILURE; + else{ + secondDriftCircleColl.reset( new MdtPrepDataCollection(secondMdtHashId) ); + idWithDataVect.push_back(secondMdtHashId); + secondDriftCircleColl->setIdentifier(secondElementId); + ATH_MSG_DEBUG("Created second MdtPrepDataCollection (not found in cache) " << secondMdtHashId); } } } @@ -651,6 +671,7 @@ StatusCode Muon::MdtRdoToPrepDataToolCore::processCsm(const MdtCsm *rdoColl, std ATH_MSG_WARNING("Detector Element not found for Identifier from the cabling service <" <<m_idHelper->toString(channelId)<<"> =>>ignore this hit"); delete newDigit; + itD++; continue; } if (!descriptor->containsId(channelId)) { @@ -658,6 +679,7 @@ StatusCode Muon::MdtRdoToPrepDataToolCore::processCsm(const MdtCsm *rdoColl, std <<" does not contains candidate prd Identifier <" <<m_idHelper->toString(channelId)<<"> =>>ignore this hit"); delete newDigit; + itD++; continue; } @@ -684,29 +706,104 @@ StatusCode Muon::MdtRdoToPrepDataToolCore::processCsm(const MdtCsm *rdoColl, std IdentifierHash hashId; if ( (!doubleCsmFound) || (!doubleCsm) ) { - collectionToBeUpdated = driftCircleColl; + collectionToBeUpdated = driftCircleColl.get(); hashId = mdtHashId; } else { - collectionToBeUpdated = secondDriftCircleColl; + collectionToBeUpdated = secondDriftCircleColl.get(); hashId = secondMdtHashId; } - MdtPrepData* newPrepData = new MdtPrepData(channelId, - hashId, - driftRadius, - cov, - descriptor, - newDigit->tdc(), - newDigit->adc(), - digitStatus); - - newPrepData->setHashAndIndex(collectionToBeUpdated->identifyHash(), collectionToBeUpdated->size()); - collectionToBeUpdated->push_back(newPrepData); + // We can make the MdtPrepData, but only if our collection is being used (ie not null) + if(collectionToBeUpdated){ + MdtPrepData* newPrepData = new MdtPrepData(channelId, + hashId, + driftRadius, + cov, + descriptor, + newDigit->tdc(), + newDigit->adc(), + digitStatus); + + newPrepData->setHashAndIndex(collectionToBeUpdated->identifyHash(), collectionToBeUpdated->size()); + collectionToBeUpdated->push_back(newPrepData); + } delete newDigit; + // Special case when we need to process two RDO for one PRD in a single pass + ++itD; + // Check if we have two containers + if(rdoColl2){ + // Check finished the first collection (second pass is handled by for-loop end condition) + if(itD == rdoColl->end()){ + ATH_MSG_DEBUG("RDO collection 1 is processed - Iterators moving to RDO collection 2"); + // Update our iterators and continue processing + itD = rdoColl2->begin(); + itD_e = rdoColl2->end(); + mc = 0; // for logging + // Update element information for next RDO + elementId = m_muonIdHelperTool->mdtIdHelper().parentID(rdoColl2->identify()); + subdetId = rdoColl2->SubDetId(); + mrodId = rdoColl2->MrodId(); + csmId = rdoColl2->CsmId(); + ATH_MSG_VERBOSE("Identifier = "<<m_idHelper->toString(elementId) + <<" subdetId/ mrodId/ csmId = "<<subdetId<<" / "<<mrodId<<" / "<<csmId); + } + } + } + // At the end, we finally tell the cache we will be putting collections into it + // Note we did not skip empty RDO in case of 2 RDO -> 1 PRD processing + // Record PRD if it is not empty + if(driftCircleColl && !driftCircleColl->empty() ){ + MdtPrepDataContainer::IDC_WriteHandle lock = m_mdtPrepDataContainer->getWriteHandle( mdtHashId ); + if( !lock.alreadyPresent() ){ + StatusCode status_lock = lock.addOrDelete(std::move( driftCircleColl )); + if (status_lock.isFailure()) { + ATH_MSG_ERROR ( "Could not insert MdtCsmPrepdataCollection into MdtCsmPrepdataContainer..." ); + return StatusCode::FAILURE; + } + } + else{ + ATH_MSG_DEBUG("MdtCsmPrepdataCollection already inside MdtCsmPrepdataContainer " << mdtHashId); + } + } + // Special treatment for empty PRD containers + if(driftCircleColl && driftCircleColl->empty() && !secondDriftCircleColl){ + // Do not record any empty PRD containers if RDO was empty + ATH_MSG_DEBUG("MdtCsmPrepdataCollection was empty as input RDO is empty " << mdtHashId); + } + if(driftCircleColl && driftCircleColl->empty() && secondDriftCircleColl){ + // If RDO was not empty, we need to record all PRD containers (even if one is empty) + ATH_MSG_DEBUG("Input RDO was not empty but 1 RDO -> 2 PRD left one MdtCsmPrepdataCollection empty"); + ATH_MSG_DEBUG("Recording empty MdtCsmPrepdataCollection " << mdtHashId); + MdtPrepDataContainer::IDC_WriteHandle lock = m_mdtPrepDataContainer->getWriteHandle( mdtHashId ); + if( !lock.alreadyPresent() ){ + StatusCode status_lock = lock.addOrDelete(std::move( driftCircleColl )); + if (status_lock.isFailure()) { + ATH_MSG_ERROR ( "Could not insert MdtCsmPrepdataCollection into MdtCsmPrepdataContainer..." ); + return StatusCode::FAILURE; + } + } + else{ + ATH_MSG_DEBUG("MdtCsmPrepdataCollection already inside MdtCsmPrepdataContainer " << mdtHashId); + } } + // Second PRD only exists if RDO was not empty and 1 RDO -> 2 PRD is activated + if(secondDriftCircleColl && !secondDriftCircleColl->empty() ){ + MdtPrepDataContainer::IDC_WriteHandle lock = m_mdtPrepDataContainer->getWriteHandle( secondMdtHashId ); + if( !lock.alreadyPresent() ){ + StatusCode status_lock = lock.addOrDelete(std::move( secondDriftCircleColl )); + if (status_lock.isFailure()) { + ATH_MSG_ERROR ( "Could not insert MdtCsmPrepdataCollection into MdtCsmPrepdataContainer..." ); + return StatusCode::FAILURE; + } + } + else{ + ATH_MSG_DEBUG("MdtCsmPrepdataCollection already inside MdtCsmPrepdataContainer " << secondMdtHashId); + } + } + return StatusCode::SUCCESS; } @@ -742,24 +839,17 @@ StatusCode Muon::MdtRdoToPrepDataToolCore::processCsmTwin(const MdtCsm *rdoColl, } ATH_MSG_VERBOSE("HashId = "<<(int)mdtHashId); - if (m_mdtPrepDataContainer->indexFind(mdtHashId)!=m_mdtPrepDataContainer->end()) { - ATH_MSG_DEBUG("In ProcessCSM - collection already contained in IDC"); - return StatusCode::FAILURE; - } - - MdtPrepDataCollection * driftCircleColl = new MdtPrepDataCollection(mdtHashId); + // Check the IDC cache (no write handles here) + MdtPrepDataContainer::IDC_WriteHandle lock = m_mdtPrepDataContainer->getWriteHandle( mdtHashId ); + if( lock.alreadyPresent() ){ + ATH_MSG_DEBUG("MdtPrepDataCollection already contained in IDC " << elementId << " " << mdtHashId); + return StatusCode::SUCCESS; + } + + std::unique_ptr<MdtPrepDataCollection> driftCircleColl ( new MdtPrepDataCollection( mdtHashId ) ); idWithDataVect.push_back(mdtHashId); driftCircleColl->setIdentifier(elementId); - ATH_MSG_DEBUG("A new MdtPrepDataCollection here with hashId " << (unsigned int)mdtHashId); - //MdtPrepDataContainer::KEY key = m_mdtPrepDataContainer->key(elementId); - - if (StatusCode::SUCCESS != m_mdtPrepDataContainer->addCollection(driftCircleColl, mdtHashId)) { - ATH_MSG_DEBUG("In ProcessCSMtwin - Couldn't record in the Container MDT Drift Circle Collection with hashID = " - << (int)mdtHashId <<" ext. id = " - << m_idHelper->toString(elementId)); - return StatusCode::FAILURE; - } - ATH_MSG_DEBUG("MdtPrepDataCollection added to the container"); + ATH_MSG_DEBUG("Created MdtPrepDataCollection (not found in cache) " << mdtHashId); // for each Csm, loop over AmtHit, converter AmtHit to digit // retrieve/create digit collection, and insert digit into collection @@ -1235,9 +1325,15 @@ StatusCode Muon::MdtRdoToPrepDataToolCore::processCsmTwin(const MdtCsm *rdoColl, } - } // end for( iter_map = mdtDigitColl.begin(); iter_map != mdtDigitColl.end(); iter_map++ ) { - + } // end for( iter_map = mdtDigitColl.begin(); iter_map != mdtDigitColl.end(); iter_map++ ) + // Finished decoding RDO to PRD, so now we record the collection in the container + StatusCode status_lock = lock.addOrDelete(std::move( driftCircleColl )); + if (status_lock.isFailure()) { + ATH_MSG_ERROR ( "Could not insert MdtCsmPrepdataCollection into MdtCsmPrepdataContainer..." ); + return StatusCode::FAILURE; + } + return StatusCode::SUCCESS; } diff --git a/MuonSpectrometer/MuonCnv/MuonMDT_CnvTools/src/MdtRdoToPrepDataToolCore.h b/MuonSpectrometer/MuonCnv/MuonMDT_CnvTools/src/MdtRdoToPrepDataToolCore.h index 798dbb313362f787ba9f126e396570f3597724de..444b22d278f1a8cd2310c0ff9142a622b09e322a 100644 --- a/MuonSpectrometer/MuonCnv/MuonMDT_CnvTools/src/MdtRdoToPrepDataToolCore.h +++ b/MuonSpectrometer/MuonCnv/MuonMDT_CnvTools/src/MdtRdoToPrepDataToolCore.h @@ -78,12 +78,12 @@ namespace Muon //new decode method for Rob based readout StatusCode decode( const std::vector<uint32_t>& robIds ) override; - StatusCode processCsm(const MdtCsm *rdoColl, std::vector<IdentifierHash>& idWithDataVect); + virtual StatusCode processCsm(const MdtCsm *rdoColl, std::vector<IdentifierHash>& idWithDataVect, const MdtCsm *rdoColl2 = nullptr); Muon::MdtDriftCircleStatus getMdtDriftRadius(const MdtDigit * digit, double& radius, double& errRadius, const MuonGM::MdtReadoutElement * descriptor); // + TWIN TUBE - StatusCode processCsmTwin(const MdtCsm *rdoColll, std::vector<IdentifierHash>& idWithDataVect); + virtual StatusCode processCsmTwin(const MdtCsm *rdoColll, std::vector<IdentifierHash>& idWithDataVect); // method to get the twin tube 2nd coordinate Muon::MdtDriftCircleStatus getMdtTwinPosition(const MdtDigit * prompt_digit, const MdtDigit * twin_digit, double& radius, double& errRadius, @@ -113,7 +113,6 @@ namespace Muon const MdtCsmContainer* getRdoContainer(); void processPRDHashes( const std::vector<IdentifierHash>& chamberHashInRobs, std::vector<IdentifierHash>& idWithDataVect ); bool handlePRDHash( IdentifierHash hash, const MdtCsmContainer& rdoContainer, std::vector<IdentifierHash>& idWithDataVect ); - void sortMdtPrdCollection( const Muon::MdtPrepDataCollection* col ); /// Muon Detector Descriptor const MuonGM::MuonDetectorManager * m_muonMgr; diff --git a/MuonSpectrometer/MuonCnv/MuonMDT_CnvTools/src/MdtRdoToPrepDataToolMT.cxx b/MuonSpectrometer/MuonCnv/MuonMDT_CnvTools/src/MdtRdoToPrepDataToolMT.cxx index 0d1831eba5b4a75701e69b21e08d3ef835db9ad4..940390f0f237fd8ab186802890fc1bfb410b4a45 100644 --- a/MuonSpectrometer/MuonCnv/MuonMDT_CnvTools/src/MdtRdoToPrepDataToolMT.cxx +++ b/MuonSpectrometer/MuonCnv/MuonMDT_CnvTools/src/MdtRdoToPrepDataToolMT.cxx @@ -14,6 +14,7 @@ Muon::MdtRdoToPrepDataToolMT::MdtRdoToPrepDataToolMT(const std::string& t, const AthAlgTool(t,n,p), MdtRdoToPrepDataToolCore(t,n,p) { + declareProperty("MdtPrdContainerCacheKey", m_prdContainerCacheKey, "Optional external cache for the MDT PRD container"); } Muon::MdtRdoToPrepDataToolMT::~MdtRdoToPrepDataToolMT() @@ -24,6 +25,7 @@ StatusCode Muon::MdtRdoToPrepDataToolMT::initialize() { ATH_MSG_VERBOSE("Starting init"); ATH_CHECK( MdtRdoToPrepDataToolCore::initialize() ); + ATH_CHECK( m_prdContainerCacheKey.initialize( !m_prdContainerCacheKey.key().empty() ) ); ATH_MSG_DEBUG("initialize() successful in " << name()); return StatusCode::SUCCESS; } @@ -35,16 +37,37 @@ StatusCode Muon::MdtRdoToPrepDataToolMT::finalize() Muon::MdtRdoToPrepDataToolMT::SetupMdtPrepDataContainerStatus Muon::MdtRdoToPrepDataToolMT::setupMdtPrepDataContainer() { - // MT version of this method always adds container. Caching will be added later. m_fullEventDone=false; SG::WriteHandle< Muon::MdtPrepDataContainer >handle(m_mdtPrepDataContainerKey); - StatusCode status = handle.record(std::make_unique<Muon::MdtPrepDataContainer>(m_muonIdHelperTool->mdtIdHelper().module_hash_max())); - if (status.isFailure() || !handle.isValid() ) { - ATH_MSG_FATAL("Could not record container of MDT PrepData Container at " << m_mdtPrepDataContainerKey.key()); - return FAILED; + // Caching of PRD container + const bool externalCachePRD = !m_prdContainerCacheKey.key().empty(); + if (!externalCachePRD) { + // without the cache we just record the container + StatusCode status = handle.record(std::make_unique<Muon::MdtPrepDataContainer>(m_muonIdHelperTool->mdtIdHelper().module_hash_max())); + if (status.isFailure() || !handle.isValid() ) { + ATH_MSG_FATAL("Could not record container of MDT PrepData Container at " << m_mdtPrepDataContainerKey.key()); + return FAILED; + } + ATH_MSG_DEBUG("Created container " << m_mdtPrepDataContainerKey.key()); + } + else { + // use the cache to get the container + SG::UpdateHandle<MdtPrepDataCollection_Cache> update(m_prdContainerCacheKey); + if (!update.isValid()){ + ATH_MSG_FATAL("Invalid UpdateHandle " << m_prdContainerCacheKey.key()); + return FAILED; + } + StatusCode status = handle.record(std::make_unique<Muon::MdtPrepDataContainer>(update.ptr())); + if (status.isFailure() || !handle.isValid() ) { + ATH_MSG_FATAL("Could not record container of MDT PrepData Container using cache " + << m_prdContainerCacheKey.key() << " - " <<m_mdtPrepDataContainerKey.key()); + return FAILED; + } + ATH_MSG_DEBUG("Created container using cache for " << m_prdContainerCacheKey.key()); } + // Pass the container from the handle m_mdtPrepDataContainer = handle.ptr(); return ADDED; } \ No newline at end of file diff --git a/MuonSpectrometer/MuonCnv/MuonMDT_CnvTools/src/MdtRdoToPrepDataToolMT.h b/MuonSpectrometer/MuonCnv/MuonMDT_CnvTools/src/MdtRdoToPrepDataToolMT.h index e7aa05e8868ddf88e6e22bb9b43402d3eef72c6f..645d933bad0097c9019edd183c004f65ba5b38e2 100644 --- a/MuonSpectrometer/MuonCnv/MuonMDT_CnvTools/src/MdtRdoToPrepDataToolMT.h +++ b/MuonSpectrometer/MuonCnv/MuonMDT_CnvTools/src/MdtRdoToPrepDataToolMT.h @@ -10,6 +10,7 @@ #define MUONMdtRdoToPrepDataToolMT_H #include "MdtRdoToPrepDataToolCore.h" +#include "MuonPrepRawData/MuonPrepDataCollection_Cache.h" namespace Muon { @@ -41,6 +42,10 @@ namespace Muon protected: virtual SetupMdtPrepDataContainerStatus setupMdtPrepDataContainer() override; + + private: + /// This is the key for the cache for the MDT PRD containers, can be empty + SG::UpdateHandleKey<MdtPrepDataCollection_Cache> m_prdContainerCacheKey ; }; } // end of namespace diff --git a/MuonSpectrometer/MuonCnv/MuonRdoToPrepData/CMakeLists.txt b/MuonSpectrometer/MuonCnv/MuonRdoToPrepData/CMakeLists.txt index 932a66cb317543859ecbff890859b9eb158049af..dc23846f25f384693a1886b5f270052b4875e153 100644 --- a/MuonSpectrometer/MuonCnv/MuonRdoToPrepData/CMakeLists.txt +++ b/MuonSpectrometer/MuonCnv/MuonRdoToPrepData/CMakeLists.txt @@ -16,13 +16,14 @@ atlas_depends_on_subdirs( PUBLIC DetectorDescription/Identifier Trigger/TrigEvent/TrigSteeringEvent DetectorDescription/IRegionSelector - MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData) + MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData + MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonTrigCoinData) # Component(s) in the package: atlas_add_component( MuonRdoToPrepData src/*.cxx src/components/*.cxx - LINK_LIBRARIES AthenaBaseComps GaudiKernel StoreGateLib SGtests Identifier TrigSteeringEvent IRegionSelector MuonPrepRawData AthViews) + LINK_LIBRARIES AthenaBaseComps GaudiKernel StoreGateLib SGtests Identifier TrigSteeringEvent IRegionSelector MuonPrepRawData MuonTrigCoinData AthViews) # Install files from the package: atlas_install_headers( MuonRdoToPrepData ) diff --git a/MuonSpectrometer/MuonCnv/MuonRdoToPrepData/src/MuonPRDCacheCreator.cxx b/MuonSpectrometer/MuonCnv/MuonRdoToPrepData/src/MuonPRDCacheCreator.cxx index 2b017caee850d686323a2bb9ea259045158ba379..0eb150e725ec45403b7fae140077e744416ba082 100644 --- a/MuonSpectrometer/MuonCnv/MuonRdoToPrepData/src/MuonPRDCacheCreator.cxx +++ b/MuonSpectrometer/MuonCnv/MuonRdoToPrepData/src/MuonPRDCacheCreator.cxx @@ -22,7 +22,9 @@ MuonPRDCacheCreator::MuonPRDCacheCreator(const std::string &name,ISvcLocator *pS m_RpcCacheKey(""), m_TgcCacheKey(""), m_sTgcCacheKey(""), - m_MmCacheKey("") + m_MmCacheKey(""), + m_RpcCoinCacheKey(""), + m_TgcCoinCacheKey("") { declareProperty("CscCacheKey", m_CscCacheKey); declareProperty("CscStripCacheKey", m_CscStripCacheKey); @@ -31,6 +33,8 @@ MuonPRDCacheCreator::MuonPRDCacheCreator(const std::string &name,ISvcLocator *pS declareProperty("TgcCacheKey", m_TgcCacheKey); declareProperty("sTgcCacheKey", m_sTgcCacheKey); declareProperty("MmCacheKey", m_MmCacheKey); + declareProperty("RpcCoinCacheKey", m_RpcCoinCacheKey); + declareProperty("TgcCoinCacheKey", m_TgcCoinCacheKey); declareProperty("DisableViewWarning", m_disableWarning); } @@ -46,16 +50,38 @@ StatusCode MuonPRDCacheCreator::initialize() { ATH_CHECK( m_TgcCacheKey.initialize( !m_TgcCacheKey.key().empty() )); ATH_CHECK( m_sTgcCacheKey.initialize( !m_sTgcCacheKey.key().empty() )); ATH_CHECK( m_MmCacheKey.initialize( !m_MmCacheKey.key().empty() )); + ATH_CHECK( m_RpcCoinCacheKey.initialize( !m_RpcCoinCacheKey.key().empty() )); + ATH_CHECK( m_TgcCoinCacheKey.initialize( !m_TgcCoinCacheKey.key().empty() )); // Retrieve ID tools ATH_CHECK( m_muonIdHelperTool.retrieve() ); + // Check we have the tools to allow us to setup cache + if( !m_muonIdHelperTool->hasCscIdHelper() && !m_CscCacheKey.key().empty() ){ + ATH_MSG_WARNING("CSC ID Helper is not available and CSC PRD cache was requested - This will not be created"); + } + if( !m_muonIdHelperTool->hasMdtIdHelper() && !m_MdtCacheKey.key().empty() ){ + ATH_MSG_WARNING("MDT ID Helper is not available and MDT PRD cache was requested - This will not be created"); + } + if( !m_muonIdHelperTool->hasRpcIdHelper() && !m_RpcCacheKey.key().empty() ){ + ATH_MSG_WARNING("RPC ID Helper is not available and RPC PRD cache was requested - This will not be created"); + } + if( !m_muonIdHelperTool->hasTgcIdHelper() && !m_TgcCacheKey.key().empty() ){ + ATH_MSG_WARNING("TGC ID Helper is not available and TGC PRD cache was requested - This will not be created"); + } + if( !m_muonIdHelperTool->hasSTgcIdHelper() && !m_sTgcCacheKey.key().empty() ){ + ATH_MSG_WARNING("STGC ID Helper is not available and STGC PRD cache was requested - This will not be created"); + } + if( !m_muonIdHelperTool->hasMmIdHelper() && !m_MmCacheKey.key().empty() ){ + ATH_MSG_WARNING("MM ID Helper is not available and MM PRD cache was requested - This will not be created"); + } + return StatusCode::SUCCESS; } bool MuonPRDCacheCreator::isInsideView(const EventContext& context) const { - const IProxyDict* proxy = context.getExtension<Atlas::ExtendedEventContext>().proxy(); + const IProxyDict* proxy = Atlas::getExtendedEventContext(context).proxy(); const SG::View* view = dynamic_cast<const SG::View*>(proxy); return view != nullptr; } @@ -70,29 +96,40 @@ StatusCode MuonPRDCacheCreator::execute (const EventContext& ctx) const { m_disableWarning = true; //only check once } - // Create all the cache containers + // Create all the cache containers (if the tools are available) // CSC - ATH_CHECK(createContainer(m_CscCacheKey, m_muonIdHelperTool->cscIdHelper().module_hash_max(), ctx)); - ATH_CHECK(createContainer(m_CscStripCacheKey, m_muonIdHelperTool->cscIdHelper().module_hash_max(), ctx)); + if( m_muonIdHelperTool->hasCscIdHelper() ){ + ATH_CHECK(createContainer(m_CscCacheKey, m_muonIdHelperTool->cscIdHelper().module_hash_max(), ctx)); + ATH_CHECK(createContainer(m_CscStripCacheKey, m_muonIdHelperTool->cscIdHelper().module_hash_max(), ctx)); + } + // MDT - auto maxHashMDTs = m_muonIdHelperTool->mdtIdHelper().stationNameIndex("BME") != -1 ? m_muonIdHelperTool->mdtIdHelper().detectorElement_hash_max() : m_muonIdHelperTool->mdtIdHelper().module_hash_max(); - ATH_CHECK(createContainer(m_MdtCacheKey, maxHashMDTs, ctx)); + if( m_muonIdHelperTool->hasMdtIdHelper() ){ + auto maxHashMDTs = m_muonIdHelperTool->mdtIdHelper().stationNameIndex("BME") != -1 ? m_muonIdHelperTool->mdtIdHelper().detectorElement_hash_max() : m_muonIdHelperTool->mdtIdHelper().module_hash_max(); + ATH_CHECK(createContainer(m_MdtCacheKey, maxHashMDTs, ctx)); + } + // RPC - ATH_CHECK(createContainer(m_RpcCacheKey, m_muonIdHelperTool->rpcIdHelper().module_hash_max(), ctx)); + if( m_muonIdHelperTool->hasRpcIdHelper() ){ + ATH_CHECK(createContainer(m_RpcCacheKey, m_muonIdHelperTool->rpcIdHelper().module_hash_max(), ctx)); + ATH_CHECK(createContainer(m_RpcCoinCacheKey, m_muonIdHelperTool->rpcIdHelper().module_hash_max(), ctx)); + } + // TGC - ATH_CHECK(createContainer(m_TgcCacheKey, m_muonIdHelperTool->tgcIdHelper().module_hash_max(), ctx)); + if( m_muonIdHelperTool->hasTgcIdHelper() ){ + ATH_CHECK(createContainer(m_TgcCacheKey, m_muonIdHelperTool->tgcIdHelper().module_hash_max(), ctx)); + ATH_CHECK(createContainer(m_TgcCoinCacheKey, m_muonIdHelperTool->tgcIdHelper().module_hash_max(), ctx)); + } + // NSW STGC - ATH_CHECK(createContainer(m_sTgcCacheKey, m_muonIdHelperTool->stgcIdHelper().module_hash_max(), ctx)); + if( m_muonIdHelperTool->hasSTgcIdHelper() ){ + ATH_CHECK(createContainer(m_sTgcCacheKey, m_muonIdHelperTool->stgcIdHelper().module_hash_max(), ctx)); + } + // NSW MM - ATH_CHECK(createContainer(m_MmCacheKey, m_muonIdHelperTool->mmIdHelper().module_hash_max(), ctx)); - - ATH_MSG_DEBUG("Created cache container " << m_CscCacheKey ); - ATH_MSG_DEBUG("Created cache container " << m_CscStripCacheKey ); - ATH_MSG_DEBUG("Created cache container " << m_MdtCacheKey ); - ATH_MSG_DEBUG("Created cache container " << m_RpcCacheKey ); - ATH_MSG_DEBUG("Created cache container " << m_TgcCacheKey ); - ATH_MSG_DEBUG("Created cache container " << m_sTgcCacheKey ); - ATH_MSG_DEBUG("Created cache container " << m_MmCacheKey ); + if( m_muonIdHelperTool->hasMmIdHelper() ){ + ATH_CHECK(createContainer(m_MmCacheKey, m_muonIdHelperTool->mmIdHelper().module_hash_max(), ctx)); + } return StatusCode::SUCCESS; } diff --git a/MuonSpectrometer/MuonCnv/MuonRdoToPrepData/src/MuonPRDCacheCreator.h b/MuonSpectrometer/MuonCnv/MuonRdoToPrepData/src/MuonPRDCacheCreator.h index 1a80c0937d02d1b573e80943e247a4330b81a5b0..41b3b48b9a68a7116d834c27400e4e492a7faabc 100644 --- a/MuonSpectrometer/MuonCnv/MuonRdoToPrepData/src/MuonPRDCacheCreator.h +++ b/MuonSpectrometer/MuonCnv/MuonRdoToPrepData/src/MuonPRDCacheCreator.h @@ -8,6 +8,7 @@ #include "GaudiKernel/ToolHandle.h" #include "MuonPrepRawData/MuonPrepDataCollection_Cache.h" +#include "MuonTrigCoinData/MuonTrigCoinData_Cache.h" #include "MuonIdHelpers/MuonIdHelperTool.h" @@ -39,6 +40,9 @@ protected: SG::WriteHandleKey<TgcPrepDataCollection_Cache> m_TgcCacheKey; SG::WriteHandleKey<sTgcPrepDataCollection_Cache> m_sTgcCacheKey; SG::WriteHandleKey<MMPrepDataCollection_Cache> m_MmCacheKey; + SG::WriteHandleKey<RpcCoinDataCollection_Cache> m_RpcCoinCacheKey; + SG::WriteHandleKey<TgcCoinDataCollection_Cache> m_TgcCoinCacheKey; + ToolHandle<Muon::MuonIdHelperTool> m_muonIdHelperTool{this, "idHelper", "Muon::MuonIdHelperTool/MuonIdHelperTool", "Handle to the MuonIdHelperTool"}; diff --git a/MuonSpectrometer/MuonConfig/python/MuonRdoDecodeConfig.py b/MuonSpectrometer/MuonConfig/python/MuonRdoDecodeConfig.py index b688aec495bfb6e214571d182deaf34476fbd48d..ac24e1dd41bbc3d4516e5524610daf75b3a15098 100644 --- a/MuonSpectrometer/MuonConfig/python/MuonRdoDecodeConfig.py +++ b/MuonSpectrometer/MuonConfig/python/MuonRdoDecodeConfig.py @@ -6,27 +6,38 @@ from AthenaCommon.Constants import DEBUG, INFO ## Small class to hold the names for cache containers, should help to avoid copy / paste errors class MuonPrdCacheNames(object): - MdtCache = "MdtPrdCache" - CscCache = "CscPrdCache" - RpcCache = "RpcPrdCache" - TgcCache = "TgcPrdCache" - sTgcCache = "sTgcPrdCache" - MmCache = "MmPrdCache" + MdtCache = "MdtPrdCache" + CscCache = "CscPrdCache" + CscStripCache = "CscStripPrdCache" + RpcCache = "RpcPrdCache" + TgcCache = "TgcPrdCache" + sTgcCache = "sTgcPrdCache" + MmCache = "MmPrdCache" + RpcCoinCache = "RpcCoinCache" + TgcCoinCache = "TgcCoinCache" ## This configuration function creates the IdentifiableCaches for PRD # # The function returns a ComponentAccumulator which should be loaded first # If a configuration wants to use the cache, they need to use the same names as defined here def MuonPrdCacheCfg(): + # Use MuonGeometryFlags to identify which configuration is being used + from AtlasGeoModel.MuonGMJobProperties import MuonGeometryFlags + acc = ComponentAccumulator() MuonPRDCacheCreator=CompFactory.MuonPRDCacheCreator - cacheCreator = MuonPRDCacheCreator(MdtCacheKey = MuonPrdCacheNames.MdtCache, - CscCacheKey = MuonPrdCacheNames.CscCache, - RpcCacheKey = MuonPrdCacheNames.RpcCache, - TgcCacheKey = MuonPrdCacheNames.TgcCache, - sTgcCacheKey = MuonPrdCacheNames.sTgcCache, - MmCacheKey = MuonPrdCacheNames.MmCache) + cacheCreator = MuonPRDCacheCreator(CscStripCacheKey = (MuonPrdCacheNames.CscStripCache if MuonGeometryFlags.hasCSC() else ""), + MdtCacheKey = MuonPrdCacheNames.MdtCache, + CscCacheKey = (MuonPrdCacheNames.CscCache if MuonGeometryFlags.hasCSC() else ""), + RpcCacheKey = MuonPrdCacheNames.RpcCache, + TgcCacheKey = MuonPrdCacheNames.TgcCache, + sTgcCacheKey = (MuonPrdCacheNames.sTgcCache if MuonGeometryFlags.hasSTGC() else ""), + MmCacheKey = (MuonPrdCacheNames.MmCache if MuonGeometryFlags.hasMM() else ""), + TgcCoinCacheKey = MuonPrdCacheNames.TgcCoinCache, + RpcCoinCacheKey = MuonPrdCacheNames.RpcCoinCache, + ) + acc.addEventAlgo( cacheCreator, primary=True ) return acc diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData/MuonPrepRawData/MuonPrepDataContainer.h b/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData/MuonPrepRawData/MuonPrepDataContainer.h index 01d8e691f6163f794df700f9ecb3d2f687108ceb..985fd62d1779abe1aeb56111260b82b9d724f784 100755 --- a/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData/MuonPrepRawData/MuonPrepDataContainer.h +++ b/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData/MuonPrepRawData/MuonPrepDataContainer.h @@ -53,7 +53,7 @@ public: MuonPrepDataContainer(unsigned int max); // Constructor with IdentifiableCache object - MuonPrepDataContainer(EventContainers::IdentifiableCache< Muon::MuonPrepDataCollection <CollectionT> >* cache); + MuonPrepDataContainer(EventContainers::IdentifiableCache<CollectionT> * cache); // Destructor: virtual ~MuonPrepDataContainer(); diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData/MuonPrepRawData/MuonPrepDataContainer.icc b/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData/MuonPrepRawData/MuonPrepDataContainer.icc index b872fac33a51c01614f16c3331c523dd5ce82a6d..454e660fd8ef6703d9fe5a6828a7eb9824f83da0 100755 --- a/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData/MuonPrepRawData/MuonPrepDataContainer.icc +++ b/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData/MuonPrepRawData/MuonPrepDataContainer.icc @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -27,7 +27,7 @@ MuonPrepDataContainer< CollectionT>::MuonPrepDataContainer(unsigned int max) : template< class CollectionT> // Constructor with IdentifiableCache: -MuonPrepDataContainer<CollectionT>::MuonPrepDataContainer(EventContainers::IdentifiableCache< Muon::MuonPrepDataCollection <CollectionT> >* cache): +MuonPrepDataContainer<CollectionT>::MuonPrepDataContainer(EventContainers::IdentifiableCache<CollectionT> * cache): IdentifiableContainer<CollectionT>(cache) {} diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData/MuonPrepRawData/MuonPrepDataDict.h b/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData/MuonPrepRawData/MuonPrepDataDict.h index 15d9f0fb09d6ea4de002ed3c934c545c504366ea..9aa34a47310dfea49bef98cdce9c6398f7ab9277 100755 --- a/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData/MuonPrepRawData/MuonPrepDataDict.h +++ b/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData/MuonPrepRawData/MuonPrepDataDict.h @@ -21,6 +21,7 @@ #include "MuonPrepRawData/sTgcPrepDataContainer.h" #include "MuonPrepRawData/MMPrepDataContainer.h" #include "AthLinks/ElementLink.h" +#include "MuonPrepRawData/MuonPrepDataCollection_Cache.h" #define EXPAND_DLV(T, suffix) \ ::DataLinkVector< Muon::MuonPrepDataCollection< T > > m_dummy_dlv_ ## suffix ; \ diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData/MuonPrepRawData/selection.xml b/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData/MuonPrepRawData/selection.xml index 65dce4844e6a755e6965554b2960d93de325508e..bde3225fac24afea29a4d6b9aa492345119930d6 100755 --- a/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData/MuonPrepRawData/selection.xml +++ b/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonPrepRawData/MuonPrepRawData/selection.xml @@ -156,5 +156,14 @@ <class name="ElementLink<Muon::MMPrepDataContainer>"/> <class name="ElementLink<Muon::MMPrepDataContainer>::Base"/> + <!-- Caches --> + <class name="CscPrepDataCollection_Cache"/> + <class name="CscStripPrepDataCollection_Cache"/> + <class name="MdtPrepDataCollection_Cache"/> + <class name="RpcPrepDataCollection_Cache"/> + <class name="TgcPrepDataCollection_Cache"/> + <class name="sTgcPrepDataCollection_Cache"/> + <class name="MMPrepDataCollection_Cache"/> + </lcgdict> diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonTrigCoinData/MuonTrigCoinData/MuonCoinDataContainer.h b/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonTrigCoinData/MuonTrigCoinData/MuonCoinDataContainer.h index e95ceb62c1aafaac3eb141b3f835024e28b84dad..0f5b7315927dc2f2521514216eda2b9bd37a24ce 100755 --- a/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonTrigCoinData/MuonTrigCoinData/MuonCoinDataContainer.h +++ b/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonTrigCoinData/MuonTrigCoinData/MuonCoinDataContainer.h @@ -41,6 +41,9 @@ public: // Constructor with parameters: MuonCoinDataContainer(unsigned int max); + + // Constructor with cache + MuonCoinDataContainer(EventContainers::IdentifiableCache<CollectionT> * cache); // Destructor: virtual ~MuonCoinDataContainer(); diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonTrigCoinData/MuonTrigCoinData/MuonCoinDataContainer.icc b/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonTrigCoinData/MuonTrigCoinData/MuonCoinDataContainer.icc index 81678d6b295c98824800adc8bc4245a90d737f29..43cbd8895d24a830a3f88fc3dc71d72c80c300f8 100755 --- a/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonTrigCoinData/MuonTrigCoinData/MuonCoinDataContainer.icc +++ b/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonTrigCoinData/MuonTrigCoinData/MuonCoinDataContainer.icc @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -16,6 +16,12 @@ MuonCoinDataContainer< CollectionT>::MuonCoinDataContainer(unsigned int max) : IdentifiableContainer<CollectionT>(max) {} +template< class CollectionT> +// Constructor with parameters: +MuonCoinDataContainer< CollectionT>::MuonCoinDataContainer(EventContainers::IdentifiableCache<CollectionT> * cache) : + IdentifiableContainer<CollectionT>(cache) +{} + template< class CollectionT> // Destructor MuonCoinDataContainer< CollectionT>::~MuonCoinDataContainer() diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonTrigCoinData/MuonTrigCoinData/MuonCoinDataDict.h b/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonTrigCoinData/MuonTrigCoinData/MuonCoinDataDict.h index 9345d3f56b0c6b1e22870cd8a2bbcd0f95d33faa..e72395f5f34450e83141f18c5628336548f5c415 100755 --- a/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonTrigCoinData/MuonTrigCoinData/MuonCoinDataDict.h +++ b/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonTrigCoinData/MuonTrigCoinData/MuonCoinDataDict.h @@ -10,6 +10,7 @@ #include "MuonTrigCoinData/TgcCoinDataContainer.h" #include "MuonTrigCoinData/RpcCoinData.h" #include "MuonTrigCoinData/RpcCoinDataContainer.h" +#include "MuonTrigCoinData/MuonTrigCoinData_Cache.h" namespace tmpMuonTrigCoinData { @@ -23,6 +24,8 @@ namespace tmpMuonTrigCoinData std::vector<Muon::MuonCoinDataCollection<Muon::TgcCoinData>* > dummy2Tgc; DataVector<Muon::MuonCoinDataCollection<Muon::RpcCoinData> > dummy1Rpc; std::vector<Muon::MuonCoinDataCollection<Muon::RpcCoinData>* > dummy2Rpc; + + }; } diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonTrigCoinData/MuonTrigCoinData/MuonTrigCoinData_Cache.h b/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonTrigCoinData/MuonTrigCoinData/MuonTrigCoinData_Cache.h new file mode 100644 index 0000000000000000000000000000000000000000..f84d3c52550d60b7ef57b7f862319081c5a25076 --- /dev/null +++ b/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonTrigCoinData/MuonTrigCoinData/MuonTrigCoinData_Cache.h @@ -0,0 +1,17 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#pragma once + +#include "EventContainers/IdentifiableCache.h" + +#include "MuonTrigCoinData/RpcCoinDataCollection.h" +#include "MuonTrigCoinData/TgcCoinDataCollection.h" + +// Typedef the different templates which are likely to be used later on +typedef EventContainers::IdentifiableCache <Muon::RpcCoinDataCollection> RpcCoinDataCollection_Cache; +typedef EventContainers::IdentifiableCache <Muon::TgcCoinDataCollection> TgcCoinDataCollection_Cache; + +CLASS_DEF( RpcCoinDataCollection_Cache, 1162490086, 1 ) +CLASS_DEF( TgcCoinDataCollection_Cache, 1080713821, 1 ) diff --git a/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonTrigCoinData/MuonTrigCoinData/selection.xml b/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonTrigCoinData/MuonTrigCoinData/selection.xml index 6027d95d85b3a37b139ce456b98a59e9d3adb3d4..2e5a89112ddd3855f0bbcd6888cc4a8ca874d6f9 100755 --- a/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonTrigCoinData/MuonTrigCoinData/selection.xml +++ b/MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonTrigCoinData/MuonTrigCoinData/selection.xml @@ -34,4 +34,7 @@ <field name="m_last" transient="true" /> <field name="m_vect" transient="true" /> </class> + + <class name="RpcCoinDataCollection_Cache" /> + <class name="TgcCoinDataCollection_Cache" /> </lcgdict> diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/MdtRawDataMonitoring/MdtRawDataMonitoring/MdtRawDataMonAlg.h b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/MdtRawDataMonitoring/MdtRawDataMonitoring/MdtRawDataMonAlg.h index f1e78ea7759350e6cc61413c53820dcaab749624..57b6698c692f5998c9373badb29d4d6e0a0b9ac6 100755 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/MdtRawDataMonitoring/MdtRawDataMonitoring/MdtRawDataMonAlg.h +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/MdtRawDataMonitoring/MdtRawDataMonitoring/MdtRawDataMonAlg.h @@ -18,7 +18,9 @@ //Core Include #include "AthenaMonitoring/AthMonitorAlgorithm.h" #include "AthenaMonitoringKernel/Monitored.h" +#include "GaudiKernel/ServiceHandle.h" #include "GaudiKernel/ToolHandle.h" +#include "AsgTools/ToolHandleArray.h" //Helper Includes #include "MuonAnalysisInterfaces/IMuonSelectionTool.h" @@ -26,7 +28,7 @@ #include "MdtRawDataMonitoring/MDTNoisyTubes.h" #include "MdtRawDataMonitoring/MDTChamber.h" #include "MuonDQAUtils/MuonDQAHistMap.h" -#include "MuonIdHelpers/MuonIdHelperTool.h" +#include "MuonIdHelpers/IMuonIdHelperSvc.h" #include "MuonReadoutGeometry/MuonDetectorManager.h" #include "TrkSegment/SegmentCollection.h" #include "AthenaMonitoring/DQAtlasReadyFilterTool.h" @@ -42,10 +44,6 @@ #include <cstdlib> #include <iostream> -class Identifier; -class IdentifierHash; -class MuonDQAHistList; - namespace Muon { class MdtPrepData; } @@ -120,8 +118,7 @@ class MdtRawDataMonAlg: public AthMonitorAlgorithm { MDTNoisyTubes* m_masked_tubes; - ToolHandle<Muon::MuonIdHelperTool> m_muonIdHelperTool{this, "idHelper", - "Muon::MuonIdHelperTool/MuonIdHelperTool", "Handle to the MuonIdHelperTool"}; + ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}; ToolHandle<CP::IMuonSelectionTool> m_muonSelectionTool; // MuonDetectorManager from the conditions store @@ -165,7 +162,6 @@ class MdtRawDataMonAlg: public AthMonitorAlgorithm { ToolHandleArray<IDQFilterTool> m_DQFilterTools; bool m_atlas_ready; - uint32_t m_firstTime; SG::ReadHandleKey<Trk::SegmentCollection> m_segm_type{this,"Eff_segm_type","MuonSegments","muon segments"}; diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/MdtRawDataMonitoring/src/MDTRawDataUtilsRun3.cxx b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/MdtRawDataMonitoring/src/MDTRawDataUtilsRun3.cxx index 4158e5770c0734dbd5faf1d437d5fd15bec2151f..a3b1a7fe678e2b3c0e51e3ea60efc2f99c4b5539 100644 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/MdtRawDataMonitoring/src/MDTRawDataUtilsRun3.cxx +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/MdtRawDataMonitoring/src/MDTRawDataUtilsRun3.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////////////// @@ -380,15 +380,15 @@ StatusCode MdtRawDataMonAlg::fillMDTMaskedTubes(IdentifierHash idHash, const std std::set<Identifier> noisyTubes = m_masked_tubes->getNoiseList(idHash); for(std::set<Identifier>::const_iterator itr = noisyTubes.begin(); itr != noisyTubes.end(); ++itr){ Identifier digcoll_id = *itr; - int mdtlayer = m_muonIdHelperTool->mdtIdHelper().tubeLayer(digcoll_id); - if (m_muonIdHelperTool->mdtIdHelper().multilayer(digcoll_id)==2) { + int mdtlayer = m_idHelperSvc->mdtIdHelper().tubeLayer(digcoll_id); + if (m_idHelperSvc->mdtIdHelper().multilayer(digcoll_id)==2) { if ( hardware_name.at(1) == 'I' && hardware_name.at(3) != '8' ) mdtlayer += 4; else mdtlayer += 3; } - int mdttube= m_muonIdHelperTool->mdtIdHelper().tube(digcoll_id) + (mdtlayer-1) * m_muonIdHelperTool->mdtIdHelper().tubeMax(digcoll_id); - ChamberTubeNumberCorrection(mdttube, hardware_name, m_muonIdHelperTool->mdtIdHelper().tube(digcoll_id), mdtlayer-1); + int mdttube= m_idHelperSvc->mdtIdHelper().tube(digcoll_id) + (mdtlayer-1) * m_idHelperSvc->mdtIdHelper().tubeMax(digcoll_id); + ChamberTubeNumberCorrection(mdttube, hardware_name, m_idHelperSvc->mdtIdHelper().tube(digcoll_id), mdtlayer-1); h->Fill(mdttube, 1); } return StatusCode::SUCCESS; @@ -402,20 +402,20 @@ void MdtRawDataMonAlg::mdtchamberId() { ATH_MSG_DEBUG("in MDT ChambersIDvector" ); - std::vector<Identifier>::const_iterator idfirst = m_muonIdHelperTool->mdtIdHelper().module_begin(); - std::vector<Identifier>::const_iterator idlast = m_muonIdHelperTool->mdtIdHelper().module_end(); + std::vector<Identifier>::const_iterator idfirst = m_idHelperSvc->mdtIdHelper().module_begin(); + std::vector<Identifier>::const_iterator idlast = m_idHelperSvc->mdtIdHelper().module_end(); - IdContext mdtModuleContext = m_muonIdHelperTool->mdtIdHelper().module_context(); + IdContext mdtModuleContext = m_idHelperSvc->mdtIdHelper().module_context(); Identifier Id; IdentifierHash Idhash; for (std::vector<Identifier>::const_iterator i = idfirst; i != idlast; i++) { Id=*i; - int gethash_code = m_muonIdHelperTool->mdtIdHelper().get_hash(Id, Idhash, &mdtModuleContext); + int gethash_code = m_idHelperSvc->mdtIdHelper().get_hash(Id, Idhash, &mdtModuleContext); m_chambersId.push_back(Id); m_chambersIdHash.push_back(Idhash); - std::string extid = m_muonIdHelperTool->mdtIdHelper().show_to_string(Id); + std::string extid = m_idHelperSvc->mdtIdHelper().show_to_string(Id); ATH_MSG_DEBUG("Adding the chamber Identifier: " << extid ); if (gethash_code == 0) { ATH_MSG_VERBOSE(" its hash Id is " << Idhash ); @@ -432,10 +432,9 @@ void MdtRawDataMonAlg::mdtchamberId() // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * int MdtRawDataMonAlg::mezzmdt(Identifier digcoll_id) const { //int mezz_chamber, int mezz_eta, int mezz_ml, int mezz_tube, int max_tube) { int TotmezzTubes = 8; - if( m_muonIdHelperTool->mdtIdHelper().tubeLayerMax(digcoll_id) == 4 ) + if( m_idHelperSvc->mdtIdHelper().tubeLayerMax(digcoll_id) == 4 ) TotmezzTubes = 6; - // if (mezz_chamber==1 || mezz_chamber==2 || mezz_chamber==8 || mezz_chamber==13) TotmezzTubes=6 ; // old way of doing things that didn't work - int Imezz = (int)((m_muonIdHelperTool->mdtIdHelper().tube(digcoll_id)-1)/TotmezzTubes) + (int)((m_muonIdHelperTool->mdtIdHelper().multilayer(digcoll_id)-1)*((m_muonIdHelperTool->mdtIdHelper().tubeMax(digcoll_id))/TotmezzTubes)); + int Imezz = (int)((m_idHelperSvc->mdtIdHelper().tube(digcoll_id)-1)/TotmezzTubes) + (int)((m_idHelperSvc->mdtIdHelper().multilayer(digcoll_id)-1)*((m_idHelperSvc->mdtIdHelper().tubeMax(digcoll_id))/TotmezzTubes)); return Imezz; } @@ -444,9 +443,9 @@ int MdtRawDataMonAlg::mezzmdt(Identifier digcoll_id) const { //int mezz_chamber, // the 'if' statements are for chambers with ML1 != ML2 // except for BIS8 -- mdtIdHelper gets the # layers wrong in this instance int MdtRawDataMonAlg::GetTubeMax( const Identifier & digcoll_id, const std::string & hardware_name ) { - int numtubes = m_muonIdHelperTool->mdtIdHelper().tubeMax(digcoll_id); - int numlayers = m_muonIdHelperTool->mdtIdHelper().tubeLayerMax(digcoll_id); - int numML = m_muonIdHelperTool->mdtIdHelper().numberOfMultilayers(digcoll_id); + int numtubes = m_idHelperSvc->mdtIdHelper().tubeMax(digcoll_id); + int numlayers = m_idHelperSvc->mdtIdHelper().tubeLayerMax(digcoll_id); + int numML = m_idHelperSvc->mdtIdHelper().numberOfMultilayers(digcoll_id); int tubeMax = numtubes * numlayers * numML; if( hardware_name.substr(0,4) == "BIS8" ) // Why does mdtIdHelper get this one wrong? @@ -519,18 +518,6 @@ void MdtRawDataMonAlg::setIsATLASReady(){ m_atlas_ready = filterresult; } -// StatusCode MdtRawDataMonAlg::GetEventNum(){ - -// m_eventNum = -1; - -// SG::ReadHandle<xAOD::EventInfo> evt(m_eventInfo); - -// m_eventNum = evt->eventNumber(); - -// return StatusCode::SUCCESS; - -// } - std::string MdtRawDataMonAlg::getChamberName(const Muon::MdtPrepData* hit) const{ return getChamberName( hit->identify() ); @@ -539,14 +526,14 @@ std::string MdtRawDataMonAlg::getChamberName(const Muon::MdtPrepData* hit) const std::string MdtRawDataMonAlg::getChamberName(Identifier id) const{ if(m_hist_hash_list) { IdentifierHash idHash; - m_muonIdHelperTool->mdtIdHelper().get_module_hash(id, idHash); + m_idHelperSvc->mdtIdHelper().get_module_hash(id, idHash); if( idHash < m_hist_hash_list->size() ) { MDTChamber* chamber = (*m_hist_hash_list)[idHash]; if(chamber) return chamber->getName(); - else return convertChamberName(m_muonIdHelperTool->mdtIdHelper().stationName(id),m_muonIdHelperTool->mdtIdHelper().stationEta(id),m_muonIdHelperTool->mdtIdHelper().stationPhi(id),"MDT"); + else return convertChamberName(m_idHelperSvc->mdtIdHelper().stationName(id),m_idHelperSvc->mdtIdHelper().stationEta(id),m_idHelperSvc->mdtIdHelper().stationPhi(id),"MDT"); } } - return convertChamberName(m_muonIdHelperTool->mdtIdHelper().stationName(id),m_muonIdHelperTool->mdtIdHelper().stationEta(id),m_muonIdHelperTool->mdtIdHelper().stationPhi(id),"MDT"); + return convertChamberName(m_idHelperSvc->mdtIdHelper().stationName(id),m_idHelperSvc->mdtIdHelper().stationEta(id),m_idHelperSvc->mdtIdHelper().stationPhi(id),"MDT"); } StatusCode MdtRawDataMonAlg::getChamber(IdentifierHash id, MDTChamber* &chamber) const{ diff --git a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/MdtRawDataMonitoring/src/MdtRawDataMonAlg.cxx b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/MdtRawDataMonitoring/src/MdtRawDataMonAlg.cxx index 6c0279f0043346301c7722b764eb217d25c45fbb..4c022c8b368020ec7d7fa561281bb8dc12e96d56 100755 --- a/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/MdtRawDataMonitoring/src/MdtRawDataMonAlg.cxx +++ b/MuonSpectrometer/MuonValidation/MuonDQA/MuonRawDataMonitoring/MdtRawDataMonitoring/src/MdtRawDataMonAlg.cxx @@ -16,9 +16,6 @@ // Subject: MDT-->Offline Muon Data Quality ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -#include "Identifier/Identifier.h" -#include "Identifier/IdentifierHash.h" - #include "MuonRIO_OnTrack/MdtDriftCircleOnTrack.h" #include "AthenaMonitoring/AthenaMonManager.h" @@ -29,7 +26,6 @@ #include "MuonDQAUtils/MuonChambersRange.h" #include "MuonDQAUtils/MuonDQAHistMap.h" #include "MuonCalibIdentifier/MuonFixedId.h" -#include "MuonIdHelpers/MdtIdHelper.h" #include "MdtCalibFitters/MTStraightLine.h" #include "MuonSegment/MuonSegment.h" @@ -192,15 +188,7 @@ MdtRawDataMonAlg::~MdtRawDataMonAlg() /*---------------------------------------------------------*/ StatusCode MdtRawDataMonAlg::initialize() /*---------------------------------------------------------*/ -{ - - //initialize to stop coverity bugs - //mdtevents_RPCtrig = 0; - //mdtevents_TGCtrig=0; - // m_time = 0; - m_firstTime = 0; - - +{ // init message stream ATH_MSG_DEBUG("initialize MdtRawDataMonAlg" ); @@ -208,30 +196,17 @@ StatusCode MdtRawDataMonAlg::initialize() ATH_MSG_DEBUG("doMdtESD: " << m_doMdtESD ); ATH_MSG_DEBUG("******************" ); - StatusCode sc; - //If Online ensure that lowStat histograms are made at the runLevel and that _lowStat suffix is suppressed //If online monitoring turn off chamber by chamber hists if(m_isOnline) m_doChamberHists = false; -// MuonDetectorManager from the conditions store + // MuonDetectorManager from the conditions store ATH_CHECK(m_DetectorManagerKey.initialize()); - sc = m_muonIdHelperTool.retrieve(); - if (sc.isFailure()) { - ATH_MSG_FATAL("Cannot get MuonIdHelperTool" ); - return StatusCode::FAILURE; - } - else { - ATH_MSG_DEBUG(" Found the MuonIdHelperTool. " ); - } + ATH_CHECK(m_idHelperSvc.retrieve()); - sc = m_DQFilterTools.retrieve(); - if( !sc ) { - ATH_MSG_ERROR("Could Not Retrieve AtlasFilterTool " << m_DQFilterTools); - return StatusCode::FAILURE; - } + ATH_CHECK(m_DQFilterTools.retrieve()); ATH_CHECK(m_muonSelectionTool.retrieve()); @@ -246,22 +221,18 @@ StatusCode MdtRawDataMonAlg::initialize() ATH_CHECK(m_key_rpc.initialize()); ATH_CHECK(m_eventInfo.initialize()); - m_BMGpresent = m_muonIdHelperTool->mdtIdHelper().stationNameIndex("BMG") != -1; + m_BMGpresent = m_idHelperSvc->mdtIdHelper().stationNameIndex("BMG") != -1; // m_BMGpresent = m_mdtIdHelper->stationNameIndex("BMG") != -1; if(m_BMGpresent){ ATH_MSG_DEBUG("Processing configuration for layouts with BMG chambers."); //conflict // m_BMGid = m_mdtIdHelper->stationNameIndex("BMG"); - m_BMGid = m_muonIdHelperTool->mdtIdHelper().stationNameIndex("BMG"); + m_BMGid = m_idHelperSvc->mdtIdHelper().stationNameIndex("BMG"); // MuonDetectorManager from the Detector Store std::string managerName="Muon"; const MuonGM::MuonDetectorManager* MuonDetMgrDS; - sc = detStore()->retrieve(MuonDetMgrDS); - if (sc.isFailure()) { - ATH_MSG_INFO("Could not find the MuonGeoModel Manager: " << managerName << " from the Detector Store! " ); - return StatusCode::FAILURE; - } else { ATH_MSG_DEBUG(" Found the MuonGeoModel Manager from the Detector Store" );} + ATH_CHECK(detStore()->retrieve(MuonDetMgrDS)); for(int phi=6; phi<8; phi++) { // phi sectors for(int eta=1; eta<4; eta++) { // eta sectors @@ -287,13 +258,13 @@ StatusCode MdtRawDataMonAlg::initialize() m_mdthitspermultilayerLumi[iecap][ilayer] = new TH2F(s.c_str(), s.c_str(), 1, 0, 1, 1, 0, 1); m_mdthitspermultilayerLumi[iecap][ilayer]->SetDirectory(0); std::string xAxis = ecap[iecap].substr(0,1) + layer[ilayer].substr(0,1) + ecap[iecap].substr(1,1); - sc=binMdtRegional(m_mdthitspermultilayerLumi[iecap][ilayer], xAxis); + ATH_CHECK(binMdtRegional(m_mdthitspermultilayerLumi[iecap][ilayer], xAxis)); if( ilayer==0 && ((iecap==0||iecap==2)) ) { s = "NumberOfHits"+MDTHits_BE[iecap/2]; m_mdthitsperchamber_InnerMiddleOuterLumi[iecap/2] = new TH2F(s.c_str(), s.c_str(), 1, 0, 1, 1, 0, 1); m_mdthitsperchamber_InnerMiddleOuterLumi[iecap/2]->SetDirectory(0); - sc=binMdtGlobal(m_mdthitsperchamber_InnerMiddleOuterLumi[iecap/2], MDTHits_BE[iecap/2].at(0) ); + ATH_CHECK(binMdtGlobal(m_mdthitsperchamber_InnerMiddleOuterLumi[iecap/2], MDTHits_BE[iecap/2].at(0))); } } } @@ -307,15 +278,15 @@ StatusCode MdtRawDataMonAlg::initialize() s = "NumberOfHitsInMDTOuter_ADCCut"; m_mdthitsperML_byLayer[enumOuter] = new TH2F(s.c_str(), s.c_str(), 1, 0, 1, 1, 0, 1); m_mdthitsperML_byLayer[enumOuter]->SetDirectory(0); - sc = binMdtGlobal_byLayer(m_mdthitsperML_byLayer[enumInner], m_mdthitsperML_byLayer[enumMiddle], m_mdthitsperML_byLayer[enumOuter]); + ATH_CHECK(binMdtGlobal_byLayer(m_mdthitsperML_byLayer[enumInner], m_mdthitsperML_byLayer[enumMiddle], m_mdthitsperML_byLayer[enumOuter])); //DEV this before was in bookHistogramsRecurrent-- problably still needed since we need to fill m_hist_hash_list?? clear_hist_map(); int counter = 0; for(std::vector<Identifier>::const_iterator itr = m_chambersId.begin(); itr != m_chambersId.end(); ++itr, ++counter){ - std::string hardware_name = convertChamberName(m_muonIdHelperTool->mdtIdHelper().stationName(*itr),m_muonIdHelperTool->mdtIdHelper().stationEta(*itr), - m_muonIdHelperTool->mdtIdHelper().stationPhi(*itr),"MDT"); + std::string hardware_name = convertChamberName(m_idHelperSvc->mdtIdHelper().stationName(*itr),m_idHelperSvc->mdtIdHelper().stationEta(*itr), + m_idHelperSvc->mdtIdHelper().stationPhi(*itr),"MDT"); //Skip Chambers That Do NOT Exist if(hardware_name=="BML6A13" || hardware_name=="BML6C13") continue; @@ -325,23 +296,6 @@ StatusCode MdtRawDataMonAlg::initialize() chamber->SetMDTHitsPerChamber_IMO_Bin(dynamic_cast<TH2F*> (m_mdthitsperchamber_InnerMiddleOuterLumi[chamber->GetBarrelEndcapEnum()])); chamber->SetMDTHitsPerML_byLayer_Bins(dynamic_cast<TH2F*> (m_mdthitspermultilayerLumi[chamber->GetRegionEnum()][chamber->GetLayerEnum()]) ,dynamic_cast<TH2F*> (m_mdthitsperML_byLayer[ (chamber->GetLayerEnum() < 3 ? chamber->GetLayerEnum() : 0) ])); - - //print here the crate to fill python list... - //int crate_region=chamber->GetRegionEnum(); - // std::string chambername = chamber->getName(); - // if(chambername.substr(0,3)=="BEE" || (chambername.substr(0,3) == "BIS" && (stationEta == 7 || stationEta == 8) )){ - // if(iregion==0) crate_region=2; - // if(iregion==1) crate_region=3; - // } - - // std::cout << "TO FILL CRATE MAP: region=" << crate_region<< " Chamber name=" << chambername << " crate = " << chamber->GetCrate() << std::endl; - /*DEV this was in bookHistogramsRecurrent, need to be reimplemented in someway - // chamber->SetMDTHitsPerChamber_IMO_Bin(dynamic_cast<TH2F*> (m_mdthitsperchamber_InnerMiddleOuter_HighOcc[chamber->GetBarrelEndcapEnum()])); - - // if(m_doChamberHists){ - // sc = bookMDTHistograms(chamber, *itr); - // } - DEV */ } ATH_MSG_DEBUG(" end of initialize " ); @@ -352,9 +306,7 @@ StatusCode MdtRawDataMonAlg::initialize() /*----------------------------------------------------------------------------------*/ StatusCode MdtRawDataMonAlg::fillHistograms(const EventContext& ctx) const /*----------------------------------------------------------------------------------*/ -{ - StatusCode sc = StatusCode::SUCCESS; - +{ int lumiblock = -1; SG::ReadHandle<xAOD::EventInfo> evt(m_eventInfo, ctx); lumiblock = evt->lumiBlock(); @@ -459,22 +411,6 @@ StatusCode MdtRawDataMonAlg::fillHistograms(const EventContext& ctx) const tp->summaryValue(ntri_eta, xAOD::numberOfTriggerEtaLayers); tp->summaryValue(n_phi, xAOD::numberOfPhiLayers); if(ntri_eta+n_phi==0) continue; - //DEV commented - not working - /* - for (const Trk::MeasurementBase* hit : *trk->measurementsOnTrack()) { - const Trk::RIO_OnTrack* rot_from_track = dynamic_cast<const Trk::RIO_OnTrack*>(hit); - if(!rot_from_track) continue; - // rot_from_track->dump(msg()); - Identifier rotId = rot_from_track->identify(); - if(!m_muonIdHelperTool->mdtIdHelper().is_mdt(rotId)) continue; - IdentifierHash mdt_idHash; - MDTChamber* mdt_chamber = 0; - m_muonIdHelperTool->mdtIdHelper().get_module_hash( rotId, mdt_idHash ); - sc = getChamber(mdt_idHash, mdt_chamber); - std::string mdt_chambername = mdt_chamber->getName(); - chambers_from_tracks.insert(mdt_chambername); - } - */ } } @@ -504,25 +440,13 @@ StatusCode MdtRawDataMonAlg::fillHistograms(const EventContext& ctx) const //======================================================================= //======================================================================= - sc = fillMDTSummaryVects(*mdtCollection, chambers_from_tracks, isNoiseBurstCandidate, trig_BARREL, trig_ENDCAP, summaryPlots); - if(sc.isSuccess()){ - ATH_MSG_DEBUG("Filled MDTSummaryHistograms " ); - } else { - ATH_MSG_ERROR("Failed to Fill MDTSummaryHistograms" ); - return sc; - } + ATH_CHECK(fillMDTSummaryVects(*mdtCollection, chambers_from_tracks, isNoiseBurstCandidate, trig_BARREL, trig_ENDCAP, summaryPlots)); + //======================================================================= //======================================================================= //======================================================================= if(m_doChamberHists){ - // if(isATLASReady()) - sc = fillMDTHistograms(*mdtCollection); - if(sc.isSuccess()) { - ATH_MSG_DEBUG("Filled MDThistograms (chamber by chamber histos)" ); - } else { - ATH_MSG_ERROR("Failed to Fill MDTHistograms" ); - return sc; - } + ATH_CHECK(fillMDTHistograms(*mdtCollection)); } std::map<std::string,float>::iterator iter_hitsperchamber = evnt_hitsperchamber_map.find(hardware_name); @@ -588,14 +512,10 @@ StatusCode MdtRawDataMonAlg::fillHistograms(const EventContext& ctx) const } MDTSegmentHistogramStruct segsPlots[4][4][16]; // [region][layer][phi] - sc=handleEvent_effCalc_fillVects( segms.cptr(), segsPlots ); - if(sc.isFailure()) { - ATH_MSG_ERROR("Couldn't handleEvent_effCalc " ); - return sc; - } - fillMDTSegmentHistograms(segsPlots); + ATH_CHECK(handleEvent_effCalc_fillVects( segms.cptr(), segsPlots )); + ATH_CHECK(fillMDTSegmentHistograms(segsPlots)); - return sc; + return StatusCode::SUCCESS; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @@ -611,7 +531,6 @@ void MdtRawDataMonAlg::fillMDTOverviewVects( const Muon::MdtPrepData* mdtCollect if(MuonDetMgr==nullptr){ ATH_MSG_ERROR("Null pointer to the read MuonDetectorManager conditions object"); return; - //return StatusCode::FAILURE; } const MuonGM::MdtReadoutElement* pReadoutElementMDT = MuonDetMgr->getMdtReadoutElement(digcoll_id); @@ -775,7 +694,7 @@ StatusCode MdtRawDataMonAlg::fillMDTSummaryVects( const Muon::MdtPrepData* mdtCo //std::string mon="MDTHits_ADCCut_"+region[iregion]+"_Mon_"+layer[ilayer]+"_Phi_"+std::to_string(stationPhi+1);; // int mlayer_n = m_mdtIdHelper->multilayer(digcoll_id); - int mlayer_n = m_muonIdHelperTool->mdtIdHelper().multilayer(digcoll_id); + int mlayer_n = m_idHelperSvc->mdtIdHelper().multilayer(digcoll_id); if(!isNoisy && adc > 0){ thisVects.adc_mon.push_back(adc); @@ -901,8 +820,6 @@ StatusCode MdtRawDataMonAlg::fillMDTSummaryVects( const Muon::MdtPrepData* mdtCo StatusCode MdtRawDataMonAlg::fillMDTSummaryHistograms( const MDTSummaryHistogramStruct (&vects)[4][4][16][4][4], int lb) const{ - StatusCode sc = StatusCode::SUCCESS; - std::string region[4]={"BA","BC","EA","EC"}; std::string layer[4]={"Inner","Middle","Outer","Extra"}; std::string crate[4]={"01","02","03","04"}; @@ -1012,7 +929,7 @@ StatusCode MdtRawDataMonAlg::fillMDTSummaryHistograms( const MDTSummaryHistogram } } - return sc; + return StatusCode::SUCCESS; } @@ -1035,16 +952,16 @@ StatusCode MdtRawDataMonAlg::fillMDTHistograms( const Muon::MdtPrepData* mdtColl // //convert layer numbering from 1->4 to 1->8 // //check if we are in 2nd multilayer // //then add 4 if large chamber, 3 if small chamber - int mdtlayer = m_muonIdHelperTool->mdtIdHelper().tubeLayer(digcoll_id); - if (m_muonIdHelperTool->mdtIdHelper().multilayer(digcoll_id)==2) { + int mdtlayer = m_idHelperSvc->mdtIdHelper().tubeLayer(digcoll_id); + if (m_idHelperSvc->mdtIdHelper().multilayer(digcoll_id)==2) { if ( hardware_name.at(1) == 'I' && hardware_name.at(3) != '8' ) mdtlayer += 4; else mdtlayer += 3; } - int mdttube= m_muonIdHelperTool->mdtIdHelper().tube(digcoll_id) + (mdtlayer-1) * m_muonIdHelperTool->mdtIdHelper().tubeMax(digcoll_id); - ChamberTubeNumberCorrection(mdttube, hardware_name, m_muonIdHelperTool->mdtIdHelper().tube(digcoll_id), mdtlayer-1); + int mdttube= m_idHelperSvc->mdtIdHelper().tube(digcoll_id) + (mdtlayer-1) * m_idHelperSvc->mdtIdHelper().tubeMax(digcoll_id); + ChamberTubeNumberCorrection(mdttube, hardware_name, m_idHelperSvc->mdtIdHelper().tube(digcoll_id), mdtlayer-1); bool isNoisy = m_masked_tubes->isNoisy( mdtCollection ); float tdc = mdtCollection->tdc()*25.0/32.0; @@ -1067,7 +984,7 @@ StatusCode MdtRawDataMonAlg::fillMDTHistograms( const Muon::MdtPrepData* mdtColl if(iregion==2) monPerCh+="EA"; if(iregion==3) monPerCh+="EC"; - int mdtMultLayer = m_muonIdHelperTool->mdtIdHelper().multilayer(digcoll_id); + int mdtMultLayer = m_idHelperSvc->mdtIdHelper().multilayer(digcoll_id); auto tdc_perch = Monitored::Scalar<float>("tdc_perch_"+hardware_name,tdc); auto adc_perch = Monitored::Scalar<float>("adc_perch_"+hardware_name, adc); @@ -1143,7 +1060,7 @@ StatusCode MdtRawDataMonAlg::handleEvent_effCalc_fillVects(const Trk::SegmentCol Identifier tmpid = rot->identify(); IdentifierHash idHash; MDTChamber* chamber = 0; - m_muonIdHelperTool->mdtIdHelper().get_module_hash( tmpid, idHash ); + m_idHelperSvc->mdtIdHelper().get_module_hash( tmpid, idHash ); sc = getChamber(idHash, chamber); std::string chambername = chamber->getName(); float adc = mrot->prepRawData()->adc(); @@ -1194,7 +1111,7 @@ StatusCode MdtRawDataMonAlg::handleEvent_effCalc_fillVects(const Trk::SegmentCol }//adc cut - int mdtMultLayer = m_muonIdHelperTool->mdtIdHelper().multilayer(tmpid); + int mdtMultLayer = m_idHelperSvc->mdtIdHelper().multilayer(tmpid); auto adc_perch = Monitored::Scalar<float>("adc_segs_perch_"+chambername, adc); auto adc_ml1 = Monitored::Scalar<int>("adc_ml1", (int) ( mdtMultLayer==1)); auto adc_ml2 = Monitored::Scalar<int>("adc_ml2", (int) (mdtMultLayer==2)); @@ -1212,9 +1129,9 @@ StatusCode MdtRawDataMonAlg::handleEvent_effCalc_fillVects(const Trk::SegmentCol // (otherwise we may not check a traversed ML for a differently pointing overlapping segment, for example) ROTs_chamber.push_back( tmpid ); - ROTs_ML.push_back( m_muonIdHelperTool->mdtIdHelper().multilayer(tmpid) ); - ROTs_L.push_back( m_muonIdHelperTool->mdtIdHelper().tubeLayer(tmpid) ); - ROTs_tube.push_back( m_muonIdHelperTool->mdtIdHelper().tube(tmpid) ); + ROTs_ML.push_back( m_idHelperSvc->mdtIdHelper().multilayer(tmpid) ); + ROTs_L.push_back( m_idHelperSvc->mdtIdHelper().tubeLayer(tmpid) ); + ROTs_tube.push_back( m_idHelperSvc->mdtIdHelper().tube(tmpid) ); ROTs_DR.push_back( mrot->driftRadius() ); ROTs_DRerr.push_back( (mrot->localCovariance())(Trk::driftRadius,Trk::driftRadius) ) ; // always returns value 2.0 ROTs_DT.push_back( mrot->driftTime() ); @@ -1255,7 +1172,7 @@ StatusCode MdtRawDataMonAlg::handleEvent_effCalc_fillVects(const Trk::SegmentCol std::vector<float> traversed_distance; for( unsigned i_chamber=0; i_chamber<unique_chambers.size(); i_chamber++) { Identifier station_id = unique_chambers.at(i_chamber); - if( !m_muonIdHelperTool->mdtIdHelper().is_mdt( station_id ) ) { + if( !m_idHelperSvc->mdtIdHelper().is_mdt( station_id ) ) { ATH_MSG_DEBUG("is_mdt() returned false in segm-based mdt eff calc" ); } std::string hardware_name = getChamberName(station_id); @@ -1272,20 +1189,20 @@ StatusCode MdtRawDataMonAlg::handleEvent_effCalc_fillVects(const Trk::SegmentCol // Loop over tubes in chamber, find those along segment for(unsigned i_ML=0; i_ML<unique_chambers_ML.at(i_chamber).size(); i_ML++) { int ML = unique_chambers_ML.at(i_chamber).at(i_ML); - Identifier newId = m_muonIdHelperTool->mdtIdHelper().channelID(hardware_name.substr(0,3), m_muonIdHelperTool->mdtIdHelper().stationEta(station_id), m_muonIdHelperTool->mdtIdHelper().stationPhi(station_id), ML, 1, 1); - int tubeMax = m_muonIdHelperTool->mdtIdHelper().tubeMax(newId); - int tubeLayerMax = m_muonIdHelperTool->mdtIdHelper().tubeLayerMax(newId); + Identifier newId = m_idHelperSvc->mdtIdHelper().channelID(hardware_name.substr(0,3), m_idHelperSvc->mdtIdHelper().stationEta(station_id), m_idHelperSvc->mdtIdHelper().stationPhi(station_id), ML, 1, 1); + int tubeMax = m_idHelperSvc->mdtIdHelper().tubeMax(newId); + int tubeLayerMax = m_idHelperSvc->mdtIdHelper().tubeLayerMax(newId); CorrectTubeMax(hardware_name, tubeMax); CorrectLayerMax(hardware_name, tubeLayerMax); - for(int i_tube=m_muonIdHelperTool->mdtIdHelper().tubeMin(newId); i_tube<=tubeMax; i_tube++) { - for(int i_layer=m_muonIdHelperTool->mdtIdHelper().tubeLayerMin(newId); i_layer<=tubeLayerMax; i_layer++) { + for(int i_tube=m_idHelperSvc->mdtIdHelper().tubeMin(newId); i_tube<=tubeMax; i_tube++) { + for(int i_layer=m_idHelperSvc->mdtIdHelper().tubeLayerMin(newId); i_layer<=tubeLayerMax; i_layer++) { const MuonGM::MdtReadoutElement* MdtRoEl = MuonDetMgr->getMdtReadoutElement( newId ); - if(m_BMGpresent && m_muonIdHelperTool->mdtIdHelper().stationName(newId) == m_BMGid ) { + if(m_BMGpresent && m_idHelperSvc->mdtIdHelper().stationName(newId) == m_BMGid ) { std::map<Identifier, std::vector<Identifier> >::const_iterator myIt = m_DeadChannels.find(MdtRoEl->identify()); if( myIt != m_DeadChannels.end() ){ - Identifier tubeId = m_muonIdHelperTool->mdtIdHelper().channelID(hardware_name.substr(0,3), m_muonIdHelperTool->mdtIdHelper().stationEta(station_id), m_muonIdHelperTool->mdtIdHelper().stationPhi(station_id), ML, i_layer, i_tube ); + Identifier tubeId = m_idHelperSvc->mdtIdHelper().channelID(hardware_name.substr(0,3), m_idHelperSvc->mdtIdHelper().stationEta(station_id), m_idHelperSvc->mdtIdHelper().stationPhi(station_id), ML, i_layer, i_tube ); if( std::find( (myIt->second).begin(), (myIt->second).end(), tubeId) != (myIt->second).end() ) { - ATH_MSG_DEBUG("Skipping tube with identifier " << m_muonIdHelperTool->mdtIdHelper().show_to_string(tubeId) ); + ATH_MSG_DEBUG("Skipping tube with identifier " << m_idHelperSvc->mdtIdHelper().show_to_string(tubeId) ); continue; } } @@ -1315,7 +1232,7 @@ StatusCode MdtRawDataMonAlg::handleEvent_effCalc_fillVects(const Trk::SegmentCol std::string hardware_name = getChamberName(traversed_station_id.at(k)); // GET HISTS IdentifierHash idHash; - m_muonIdHelperTool->mdtIdHelper().get_module_hash( traversed_station_id.at(k), idHash ); + m_idHelperSvc->mdtIdHelper().get_module_hash( traversed_station_id.at(k), idHash ); MDTChamber* chamber; sc = getChamber( idHash, chamber ); if(!sc.isSuccess()){ @@ -1325,26 +1242,19 @@ StatusCode MdtRawDataMonAlg::handleEvent_effCalc_fillVects(const Trk::SegmentCol bool hit_flag = false; for (unsigned j=0; j<ROTs_tube.size(); j++) { - // if( (convertChamberName(m_muonIdHelperTool->mdtIdHelper().stationName(ROTs_chamber.at(j)), m_muonIdHelperTool->mdtIdHelper().stationEta(ROTs_chamber.at(j)), m_muonIdHelperTool->mdtIdHelper().stationPhi(ROTs_chamber.at(j)),type) == hardware_name) - // && (traversed_tube.at(k)==ROTs_tube.at(j)) && (traversed_L.at(k)==ROTs_L.at(j)) && (traversed_ML.at(k)==ROTs_ML.at(j))) { // found traversed tube with hit used in segment if( (getChamberName(ROTs_chamber.at(j)) == hardware_name) && (traversed_tube.at(k)==ROTs_tube.at(j)) && (traversed_L.at(k)==ROTs_L.at(j)) && (traversed_ML.at(k)==ROTs_ML.at(j))) { // found traversed tube with hit used in segment hit_flag = true; - /*DEV - if(chamber->mdt_DRvsDT) chamber->mdt_DRvsDT->Fill(ROTs_DR.at(j), ROTs_DT.at(j)); - if(chamber->mdt_DRvsDRerr) chamber->mdt_DRvsDRerr->Fill(ROTs_DR.at(j), ROTs_DRerr.at(j)); // plot appears useless - if(chamber->mdt_DRvsSegD) chamber->mdt_DRvsSegD->Fill(ROTs_DR.at(j), traversed_distance.at(k)); - DEV*/ break; } } - Identifier newId = m_muonIdHelperTool->mdtIdHelper().channelID(hardware_name.substr(0,3), m_muonIdHelperTool->mdtIdHelper().stationEta(traversed_station_id.at(k)), m_muonIdHelperTool->mdtIdHelper().stationPhi(traversed_station_id.at(k)), traversed_ML.at(k), 1, 1); - int tubeLayerMax = m_muonIdHelperTool->mdtIdHelper().tubeLayerMax(newId); - m_muonIdHelperTool->mdtIdHelper().get_module_hash( newId, idHash ); + Identifier newId = m_idHelperSvc->mdtIdHelper().channelID(hardware_name.substr(0,3), m_idHelperSvc->mdtIdHelper().stationEta(traversed_station_id.at(k)), m_idHelperSvc->mdtIdHelper().stationPhi(traversed_station_id.at(k)), traversed_ML.at(k), 1, 1); + int tubeLayerMax = m_idHelperSvc->mdtIdHelper().tubeLayerMax(newId); + m_idHelperSvc->mdtIdHelper().get_module_hash( newId, idHash ); CorrectLayerMax(hardware_name, tubeLayerMax); // ChamberTubeNumberCorrection handles the tubeMax problem int mdtlayer = ( (traversed_L.at(k) - 1) + (traversed_ML.at(k) - 1) * tubeLayerMax ); - int ibin = traversed_tube.at(k) + mdtlayer * m_muonIdHelperTool->mdtIdHelper().tubeMax(newId); + int ibin = traversed_tube.at(k) + mdtlayer * m_idHelperSvc->mdtIdHelper().tubeMax(newId); ChamberTubeNumberCorrection(ibin, hardware_name, traversed_tube.at(k), mdtlayer); // Store info for eff calc // (Here we make sure we are removing duplicates from overlapping segments by using sets) @@ -1393,7 +1303,6 @@ StatusCode MdtRawDataMonAlg::handleEvent_effCalc_fillVects(const Trk::SegmentCol } StatusCode MdtRawDataMonAlg::fillMDTSegmentHistograms( const MDTSegmentHistogramStruct (&vects)[4][4][16]) const{ - StatusCode sc = StatusCode::SUCCESS; std::string region[4]={"BA","BC","EA","EC"}; std::string layer[4]={"Inner","Middle","Outer","Extra"}; @@ -1425,7 +1334,7 @@ StatusCode MdtRawDataMonAlg::fillMDTSegmentHistograms( const MDTSegmentHistogram } } } - return sc; + return StatusCode::SUCCESS; } void MdtRawDataMonAlg::initDeadChannels(const MuonGM::MdtReadoutElement* mydetEl) { @@ -1435,10 +1344,10 @@ void MdtRawDataMonAlg::initDeadChannels(const MuonGM::MdtReadoutElement* mydetEl Identifier detElId = mydetEl->identify(); - int name = m_muonIdHelperTool->mdtIdHelper().stationName(detElId); - int eta = m_muonIdHelperTool->mdtIdHelper().stationEta(detElId); - int phi = m_muonIdHelperTool->mdtIdHelper().stationPhi(detElId); - int ml = m_muonIdHelperTool->mdtIdHelper().multilayer(detElId); + int name = m_idHelperSvc->mdtIdHelper().stationName(detElId); + int eta = m_idHelperSvc->mdtIdHelper().stationEta(detElId); + int phi = m_idHelperSvc->mdtIdHelper().stationPhi(detElId); + int ml = m_idHelperSvc->mdtIdHelper().multilayer(detElId); std::vector<Identifier> deadTubes; for(int layer = 1; layer <= mydetEl->getNLayers(); layer++){ @@ -1454,7 +1363,7 @@ void MdtRawDataMonAlg::initDeadChannels(const MuonGM::MdtReadoutElement* mydetEl if( layergeo > layer ) break; // don't loop any longer if you cannot find tube anyway anymore } if(!tubefound) { - Identifier deadTubeId = m_muonIdHelperTool->mdtIdHelper().channelID( name, eta, phi, ml, layer, tube ); + Identifier deadTubeId = m_idHelperSvc->mdtIdHelper().channelID( name, eta, phi, ml, layer, tube ); deadTubes.push_back( deadTubeId ); ATH_MSG_VERBOSE("adding dead tube (" << tube << "), layer(" << layer << "), phi(" << phi << "), eta(" << eta << "), name(" << name diff --git a/Reconstruction/tauRec/src/TauProcessorAlg.cxx b/Reconstruction/tauRec/src/TauProcessorAlg.cxx index be9e34648e65e8ee981e19b7fa3901aa1a8eac83..cb1ed787b529905a4230b5a27999867763e9a4e2 100644 --- a/Reconstruction/tauRec/src/TauProcessorAlg.cxx +++ b/Reconstruction/tauRec/src/TauProcessorAlg.cxx @@ -3,6 +3,7 @@ */ #include "GaudiKernel/ListItem.h" +#include "GaudiKernel/SystemOfUnits.h" #include "tauRec/TauProcessorAlg.h" @@ -23,6 +24,8 @@ #include "CaloInterface/ICaloCellMakerTool.h" #include "NavFourMom/INavigable4MomentumCollection.h" +using Gaudi::Units::GeV; + //----------------------------------------------------------------------------- // Constructor //----------------------------------------------------------------------------- @@ -31,7 +34,7 @@ TauProcessorAlg::TauProcessorAlg(const std::string &name, AthAlgorithm(name, pSvcLocator), m_tools(this), //make tools private m_maxEta(2.5), -m_minPt(10000), +m_minPt(10 * GeV), m_cellMakerTool("",this) { declareProperty("Tools", m_tools); diff --git a/Reconstruction/tauRec/src/components/tauRec_entries.cxx b/Reconstruction/tauRec/src/components/tauRec_entries.cxx index 2593eec8f0a2a8e0e1c427408899e442ed4f00ca..fbfba38bd321bdd53d562bc87f5962b8c21458a9 100644 --- a/Reconstruction/tauRec/src/components/tauRec_entries.cxx +++ b/Reconstruction/tauRec/src/components/tauRec_entries.cxx @@ -1,12 +1,5 @@ -// #include "tauRec/TauBuilder.h" -// #include "tauRec/TauProcessor.h" #include "tauRec/TauProcessorAlg.h" #include "tauRec/TauRunnerAlg.h" - -// DECLARE_COMPONENT( TauBuilder ) -// DECLARE_COMPONENT( TauProcessor ) DECLARE_COMPONENT( TauProcessorAlg ) DECLARE_COMPONENT( TauRunnerAlg ) - - diff --git a/Reconstruction/tauRecTools/Root/TauCalibrateLC.cxx b/Reconstruction/tauRecTools/Root/TauCalibrateLC.cxx index 894e1bf95504a5af284e7e07da8ff0055d6cf585..47a29543ca153775c57df77de33f177e8dca67e1 100644 --- a/Reconstruction/tauRecTools/Root/TauCalibrateLC.cxx +++ b/Reconstruction/tauRecTools/Root/TauCalibrateLC.cxx @@ -2,6 +2,8 @@ Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ +#include "GaudiKernel/SystemOfUnits.h" + //tau #include "tauRecTools/TauCalibrateLC.h" #include "xAODTau/TauJet.h" @@ -11,13 +13,7 @@ #include "TF1.h" #include "TH1D.h" -#ifndef XAOD_STANDALONE -#include "CLHEP/Vector/LorentzVector.h" -#include "CLHEP/Units/SystemOfUnits.h" -using CLHEP::GeV; -#else -#define GeV 1000 -#endif +using Gaudi::Units::GeV; /********************************************************************/ TauCalibrateLC::TauCalibrateLC(const std::string& name) : diff --git a/Reconstruction/tauRecTools/Root/TauEleOLRDecorator.cxx b/Reconstruction/tauRecTools/Root/TauEleOLRDecorator.cxx index e623a5a0180a43d845e3cdf455b2646e2e6409a5..7285cc82e6a5f00c593e032204b5691067abc7e4 100644 --- a/Reconstruction/tauRecTools/Root/TauEleOLRDecorator.cxx +++ b/Reconstruction/tauRecTools/Root/TauEleOLRDecorator.cxx @@ -9,10 +9,14 @@ * Modified: Lorenz Hauswald */ +#include "GaudiKernel/SystemOfUnits.h" + #include "tauRecTools/TauEleOLRDecorator.h" #include "ElectronPhotonSelectorTools/AsgElectronLikelihoodTool.h" #include "TFile.h" +using Gaudi::Units::GeV; + TauEleOLRDecorator::TauEleOLRDecorator(const std::string& name): TauRecToolBase(name), m_tEMLHTool(nullptr), @@ -62,7 +66,7 @@ StatusCode TauEleOLRDecorator::execute(xAOD::TauJet& tau) float fEleMatchPt = -1.; // find electron with pt>5GeV within 0.4 cone with largest pt for( const xAOD::Electron* xElectron : *electronContainer ) { - if(xElectron->pt() < 5000.) continue; + if(xElectron->pt() < 5.0 * GeV) continue; if(xElectron->p4().DeltaR( tau.p4() ) > 0.4 ) continue; if(xElectron->pt() > fEleMatchPt ) { fEleMatchPt=xElectron->pt(); @@ -86,7 +90,7 @@ StatusCode TauEleOLRDecorator::execute(xAOD::TauJet& tau) bool bPass = false; if (tau.nTracks() == 1) { - bPass = (fLHScore <= getCutVal(tau.track(0)->eta(), tau.pt()/1000.)); + bPass = (fLHScore <= getCutVal(tau.track(0)->eta(), tau.pt() / GeV)); } else { bPass = true; diff --git a/Reconstruction/tauRecTools/Root/TauIDVarCalculator.cxx b/Reconstruction/tauRecTools/Root/TauIDVarCalculator.cxx index c39c5395e59adc353a59a07b2d9f18ade355bfff..8ebf21c378ed6a5ec354e94914687f7dd1d6ff88 100644 --- a/Reconstruction/tauRecTools/Root/TauIDVarCalculator.cxx +++ b/Reconstruction/tauRecTools/Root/TauIDVarCalculator.cxx @@ -8,6 +8,8 @@ * Author: Lorenz Hauswald */ +#include "GaudiKernel/SystemOfUnits.h" + #include "tauRecTools/HelperFunctions.h" #include "tauRecTools/TauIDVarCalculator.h" #include "xAODTracking/VertexContainer.h" @@ -15,6 +17,7 @@ #include "FourMomUtils/xAODP4Helpers.h" #include "TLorentzVector.h" +using Gaudi::Units::GeV; const float TauIDVarCalculator::LOW_NUMBER = -1111.; TauIDVarCalculator::TauIDVarCalculator(const std::string& name): @@ -224,7 +227,7 @@ StatusCode TauIDVarCalculator::execute(xAOD::TauJet& tau) float ptLeadTrkOverEt = etOverpTLeadTrk > 0 ? 1. / etOverpTLeadTrk : LOW_NUMBER; acc_corrftrk(tau) = ptLeadTrkOverEt != -1111. ? ptLeadTrkOverEt + correction : ptLeadTrkOverEt; - acc_centFracCorrected(tau) = tau.pt() < 80*1000. ? acc_centFrac(tau) + correction : acc_centFrac(tau); + acc_centFracCorrected(tau) = tau.pt() < 80. * GeV ? acc_centFrac(tau) + correction : acc_centFrac(tau); return StatusCode::SUCCESS; } diff --git a/Reconstruction/tauRecTools/Root/TauJetRNNUtils.cxx b/Reconstruction/tauRecTools/Root/TauJetRNNUtils.cxx index 7f505f208b9d056c28750ec134ec9f41baacb6bd..cc1ab948b30aff6de8239b283b6e5c7964d80914 100644 --- a/Reconstruction/tauRecTools/Root/TauJetRNNUtils.cxx +++ b/Reconstruction/tauRecTools/Root/TauJetRNNUtils.cxx @@ -2,8 +2,12 @@ Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ +#include "GaudiKernel/SystemOfUnits.h" + #include "tauRecTools/TauJetRNNUtils.h" +using Gaudi::Units::GeV; + namespace TauJetRNNUtils { VarCalc::VarCalc() : asg::AsgMessaging("TauJetRNNUtils::VarCalc") { @@ -226,17 +230,17 @@ bool massTrkSys(const xAOD::TauJet &tau, double &out) { } bool pt(const xAOD::TauJet &tau, double &out) { - out = TMath::Log10(std::min(tau.pt() / 1000.0, 100.0)); + out = TMath::Log10(std::min(tau.pt() / GeV, 100.0)); return true; } bool ptDetectorAxis(const xAOD::TauJet &tau, double &out) { - out = TMath::Log10(std::min(tau.ptDetectorAxis() / 1000.0, 100.0)); + out = TMath::Log10(std::min(tau.ptDetectorAxis() / GeV, 100.0)); return true; } bool ptIntermediateAxis(const xAOD::TauJet &tau, double &out) { - out = TMath::Log10(std::min(tau.ptIntermediateAxis() / 1000.0, 100.0)); + out = TMath::Log10(std::min(tau.ptIntermediateAxis() /GeV, 100.0)); return true; } diff --git a/Reconstruction/tauRecTools/Root/TauSubstructureVariables.cxx b/Reconstruction/tauRecTools/Root/TauSubstructureVariables.cxx index 6af3b303ba94447bf84226b36c182b804e08593b..8b53fa6b29dfb676bba3a34a142fec52edd36f69 100644 --- a/Reconstruction/tauRecTools/Root/TauSubstructureVariables.cxx +++ b/Reconstruction/tauRecTools/Root/TauSubstructureVariables.cxx @@ -21,12 +21,8 @@ #include "tauRecTools/KineUtils.h" -#ifndef XAOD_ANALYSIS #include "GaudiKernel/SystemOfUnits.h" using Gaudi::Units::GeV; -#else -#define GeV 1000 -#endif const double TauSubstructureVariables::DEFAULT = -1111.; diff --git a/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfig.py b/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfig.py index 793ca70c42ac86dc566a54434eb43f5971799441..82cae47f428f86123792d9ea1904f3ad480cad6b 100644 --- a/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfig.py +++ b/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfig.py @@ -572,6 +572,9 @@ def triggerIDCCacheCreatorsCfg(flags): from MuonConfig.MuonBytestreamDecodeConfig import MuonCacheCfg acc.merge( MuonCacheCfg() ) + from MuonConfig.MuonRdoDecodeConfig import MuonPrdCacheCfg + acc.merge( MuonPrdCacheCfg() ) + from TrigInDetConfig.InDetConfig import InDetIDCCacheCreatorCfg acc.merge( InDetIDCCacheCreatorCfg() ) diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Muon/MuonSetup.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Muon/MuonSetup.py index 5ac082087022c6e29c2fa9afe22ece4a10a3d157..5dd33938b250f48e081e3ed91f9ee13ea0af008f 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Muon/MuonSetup.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Muon/MuonSetup.py @@ -10,6 +10,7 @@ log = logging.getLogger('MuonSetup') ### Output data name ### from TrigEDMConfig.TriggerEDMRun3 import recordable from MuonConfig.MuonBytestreamDecodeConfig import MuonCacheNames +from MuonConfig.MuonRdoDecodeConfig import MuonPrdCacheNames TrackParticlesName = recordable("HLT_IDTrack_Muon_FTF") theFTF_name = "FTFTracks_Muons" @@ -78,9 +79,10 @@ def makeMuonPrepDataAlgs(RoIs="MURoIs", forFullScan=False): Decoder = CSCRodDecoder ) ToolSvc += MuonCscRawDataProviderTool - from MuonCSC_CnvTools.MuonCSC_CnvToolsConf import Muon__CscRdoToCscPrepDataTool - CscRdoToCscPrepDataTool = Muon__CscRdoToCscPrepDataTool(name = "CscRdoToCscPrepDataTool") - + from MuonCSC_CnvTools.MuonCSC_CnvToolsConf import Muon__CscRdoToCscPrepDataToolMT + CscRdoToCscPrepDataTool = Muon__CscRdoToCscPrepDataToolMT(name = "CscRdoToCscPrepDataTool", + CscStripPrdContainerCacheKey = MuonPrdCacheNames.CscStripCache) + ToolSvc += CscRdoToCscPrepDataTool from MuonRdoToPrepData.MuonRdoToPrepDataConf import CscRdoToCscPrepData @@ -123,8 +125,9 @@ def makeMuonPrepDataAlgs(RoIs="MURoIs", forFullScan=False): Decoder = MDTRodDecoder ) ToolSvc += MuonMdtRawDataProviderTool - from MuonMDT_CnvTools.MuonMDT_CnvToolsConf import Muon__MdtRdoToPrepDataTool - MdtRdoToMdtPrepDataTool = Muon__MdtRdoToPrepDataTool(name = "MdtRdoToPrepDataTool") + from MuonMDT_CnvTools.MuonMDT_CnvToolsConf import Muon__MdtRdoToPrepDataToolMT + MdtRdoToMdtPrepDataTool = Muon__MdtRdoToPrepDataToolMT(name = "MdtRdoToPrepDataTool", + MdtPrdContainerCacheKey = MuonPrdCacheNames.MdtCache) ToolSvc += MdtRdoToMdtPrepDataTool @@ -162,6 +165,13 @@ def makeMuonPrepDataAlgs(RoIs="MURoIs", forFullScan=False): from MuonRPC_CnvTools.MuonRPC_CnvToolsConf import Muon__RpcRdoToPrepDataTool RpcRdoToRpcPrepDataTool = Muon__RpcRdoToPrepDataTool(name = "RpcRdoToPrepDataTool") + + #from MuonRPC_CnvTools.MuonRPC_CnvToolsConf import Muon__RpcRdoToPrepDataToolMT + #RpcRdoToRpcPrepDataTool = Muon__RpcRdoToPrepDataToolMT(name = "RpcRdoToPrepDataTool", + # RpcPrdContainerCacheKey = MuonPrdCacheNames.RpcCache, + # RpcCoinContainerCacheKey = MuonPrdCacheNames.RpcCoinCache) + #RpcRdoToRpcPrepDataTool.OutputLevel = DEBUG + if athenaCommonFlags.isOnline: RpcRdoToRpcPrepDataTool.ReadKey = ""