From e8a1b453b89d49515ce0ee1e3aa75ce799782b5a Mon Sep 17 00:00:00 2001 From: Scott Snyder <scott.snyder@cern.ch> Date: Tue, 14 May 2019 18:45:17 +0000 Subject: [PATCH] TrackToCalo: Migrate from CaloNoiseTool to CaloNoise conditions object. Migrate CaloCellCollector from CaloNoiseTool to CaloNoise conditions object. Remove a bad const_cast in passing. --- .../src/MuonCreatorTool.cxx | 38 +++++++++---------- .../src/MuonCreatorTool.h | 10 ++--- .../TrackToCalo/CaloCellCollector.h | 7 ++-- .../TrackToCalo/src/CaloCellCollector.cxx | 24 +++--------- .../python/HLTMenuConfig/Muon/MuonSetup.py | 2 +- 5 files changed, 32 insertions(+), 49 deletions(-) diff --git a/Reconstruction/MuonIdentification/MuonCombinedBaseTools/src/MuonCreatorTool.cxx b/Reconstruction/MuonIdentification/MuonCombinedBaseTools/src/MuonCreatorTool.cxx index 521c7a6568e..235164ca622 100644 --- a/Reconstruction/MuonIdentification/MuonCombinedBaseTools/src/MuonCreatorTool.cxx +++ b/Reconstruction/MuonIdentification/MuonCombinedBaseTools/src/MuonCreatorTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ ///////////////////////////////////////////////////////////////////////////// @@ -72,6 +72,8 @@ #include "TrackSegmentAssociationTool.h" #include "MuonIdHelpers/MuonStationIndex.h" +#include "StoreGate/ReadCondHandle.h" + //#include "xAODTruth/TruthEventContainer.h" @@ -97,7 +99,6 @@ namespace MuonCombined { m_selectorTool("CP::MuonSelectionTool/MuonSelectionTool"), m_muonSegmentConverterTool("Muon::MuonSegmentConverterTool/MuonSegmentConverterTool"), m_meanMDTdADCTool("Rec::MuonMeanMDTdADCFillerTool/MuonMeanMDTdADCFillerTool"), - m_caloNoiseTool(""), m_caloMaterialProvider("Trk::TrkMaterialProviderTool/TrkMaterialProviderTool", this), m_trackSegmentAssociationTool("Muon::TrackSegmentAssociationTool/TrackSegmentAssociationTool"), m_trackQuery("Rec::MuonTrackQuery/MuonTrackQuery") @@ -125,8 +126,6 @@ namespace MuonCombined { declareProperty("PrintSummary", m_printSummary=false); declareProperty("UseUpdatedExtrapolatedTrack", m_useUpdatedExtrapolatedTrack = true ); //Default data source for the calocells - declareProperty("CaloNoiseTool", m_caloNoiseTool); - declareProperty("DoCaloNoiseCut", m_applyCaloNoiseCut=false); declareProperty("SigmaCaloNoiseCut", m_sigmaCaloNoiseCut=3.4); declareProperty("CaloMaterialProvider", m_caloMaterialProvider); declareProperty("FillTimingInformation", m_fillTimingInformation = true ); @@ -167,17 +166,11 @@ namespace MuonCombined { else m_selectorTool.disable(); if(!m_meanMDTdADCTool.empty()) ATH_CHECK(m_meanMDTdADCTool.retrieve()); else m_meanMDTdADCTool.disable(); - if(m_applyCaloNoiseCut) { - // apply CaloNoiseTool to cell collected for ET_Core - if(!m_caloNoiseTool.empty()) ATH_CHECK(m_caloNoiseTool.retrieve()); - else { - if (m_applyCaloNoiseCut) ATH_MSG_WARNING("YOU MUST PROVIDE NAME of CaloNoiseTool for ET_Core cell collection."); - m_applyCaloNoiseCut = false; - } - } - else m_caloNoiseTool.disable(); - ATH_MSG_INFO("ET_Core calculation: tool, doNoiseCut, sigma - " << m_caloNoiseTool.name() << " " - << m_applyCaloNoiseCut << " " << m_sigmaCaloNoiseCut); + + ATH_CHECK( m_caloNoiseKey.initialize (SG::AllowEmpty) ); + + ATH_MSG_INFO("ET_Core calculation: doNoiseCut, sigma - " + << !m_caloNoiseKey.empty() << " " << m_sigmaCaloNoiseCut); if(!m_doSA){ ATH_CHECK(m_caloMaterialProvider.retrieve()); @@ -1665,20 +1658,25 @@ namespace MuonCombined { ElementLink< xAOD::CaloClusterContainer > clusterLink(*clusterContainer,clusterContainer->size()-1); muon.setClusterLink(clusterLink); + const CaloNoise* caloNoise = nullptr; + if (!m_caloNoiseKey.empty()) { + SG::ReadCondHandle<CaloNoise> noiseH (m_caloNoiseKey); + caloNoise = noiseH.cptr(); + } + // collect the core energy std::vector<float> etcore(4, 0); - m_cellCollector.collectEtCore( *cluster, etcore, m_caloNoiseTool, m_applyCaloNoiseCut, m_sigmaCaloNoiseCut ); + m_cellCollector.collectEtCore( *cluster, etcore, caloNoise, m_sigmaCaloNoiseCut ); muon.auxdata< float >("ET_Core") = etcore[Rec::CaloCellCollector::ET_Core]; muon.auxdata< float >("ET_EMCore") = etcore[Rec::CaloCellCollector::ET_EMCore]; muon.auxdata< float >("ET_TileCore") = etcore[Rec::CaloCellCollector::ET_TileCore]; muon.auxdata< float >("ET_HECCore") = etcore[Rec::CaloCellCollector::ET_HECCore]; - if( m_caloNoiseTool.empty() ) - ATH_MSG_DEBUG("NO Tool for calo noise,apply,sigma: " << "/" << m_applyCaloNoiseCut << "/" + if( m_caloNoiseKey.empty() ) + ATH_MSG_DEBUG("NO Tool for calo noise,sigma: " << m_sigmaCaloNoiseCut); else - ATH_MSG_DEBUG("Tool,apply,sigma: " << m_caloNoiseTool->name() << "/" << m_applyCaloNoiseCut << "/" - << m_sigmaCaloNoiseCut); + ATH_MSG_DEBUG("sigma: " << m_sigmaCaloNoiseCut); ATH_MSG_DEBUG("Etcore: tot/em/tile/hec " << etcore[Rec::CaloCellCollector::ET_Core] << "/" << etcore[Rec::CaloCellCollector::ET_EMCore] << "/" diff --git a/Reconstruction/MuonIdentification/MuonCombinedBaseTools/src/MuonCreatorTool.h b/Reconstruction/MuonIdentification/MuonCombinedBaseTools/src/MuonCreatorTool.h index 485b6ea0b7c..a6a97c448f6 100644 --- a/Reconstruction/MuonIdentification/MuonCombinedBaseTools/src/MuonCreatorTool.h +++ b/Reconstruction/MuonIdentification/MuonCombinedBaseTools/src/MuonCreatorTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MUONCOMBINEDBASETOOLS_MUONCREATORTOOL_H @@ -33,10 +33,11 @@ #include "TrkSegment/Segment.h" #include "MuonSegment/MuonSegment.h" #include "TrackToCalo/CaloCellCollector.h" -#include "CaloInterface/ICaloNoiseTool.h" #include "CaloEvent/CaloCellContainer.h" +#include "CaloConditions/CaloNoise.h" #include "StoreGate/ReadHandleKey.h" +#include "StoreGate/ReadCondHandleKey.h" namespace Muon { class MuonEDMPrinterTool; @@ -173,9 +174,6 @@ namespace MuonCombined { /// configure whether to use the updated extrapolated track for a combined fit or not bool m_useUpdatedExtrapolatedTrack; - /// Flag to apply noise cut to calo cells around muons - bool m_applyCaloNoiseCut; - /// Number of sigma for calo cell noise cut float m_sigmaCaloNoiseCut; @@ -214,12 +212,12 @@ namespace MuonCombined { ToolHandle<CP::IMuonSelectionTool> m_selectorTool; ToolHandle<xAODMaker::IMuonSegmentConverterTool> m_muonSegmentConverterTool; ToolHandle<Rec::IMuonMeanMDTdADCFiller> m_meanMDTdADCTool; - ToolHandle <ICaloNoiseTool> m_caloNoiseTool; ToolHandle<Trk::ITrkMaterialProviderTool> m_caloMaterialProvider; ToolHandle<Muon::TrackSegmentAssociationTool> m_trackSegmentAssociationTool; ToolHandle<Rec::IMuonTrackQuery> m_trackQuery; Rec::CaloCellCollector m_cellCollector; SG::ReadHandleKey<CaloCellContainer> m_cellContainerName{this,"CaloCellContainer","AllCalo","calo cells"}; + SG::ReadCondHandleKey<CaloNoise> m_caloNoiseKey{this,"CaloNoise","","CaloNoise object to use, or blank."}; }; inline void MuonCreatorTool::setP4( xAOD::Muon& muon, const xAOD::TrackParticle& tp ) const { diff --git a/Reconstruction/RecoTools/TrackToCalo/TrackToCalo/CaloCellCollector.h b/Reconstruction/RecoTools/TrackToCalo/TrackToCalo/CaloCellCollector.h index 9f8929dbdb7..3e40536500a 100644 --- a/Reconstruction/RecoTools/TrackToCalo/TrackToCalo/CaloCellCollector.h +++ b/Reconstruction/RecoTools/TrackToCalo/TrackToCalo/CaloCellCollector.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef TRACKTOCALO_CALOCELLCOLLECTOR_H @@ -14,7 +14,7 @@ // forward declarations namespace Trk { class CaloExtension; } class CaloCellContainer; -class ICaloNoiseTool; +class CaloNoise; namespace Rec { @@ -38,8 +38,7 @@ namespace Rec { void collectEtCore( const xAOD::CaloCluster& cluster, std::vector<float>& et_core, - const ToolHandle <ICaloNoiseTool>& caloNoiseTool, - bool applyNoiseCut = true, + const CaloNoise* caloNoise, float sigmaNoiseCut = 3.4) const; void resetCoreParameters (const std::vector<std::pair<float, float> >& dEtadPhiCore, diff --git a/Reconstruction/RecoTools/TrackToCalo/src/CaloCellCollector.cxx b/Reconstruction/RecoTools/TrackToCalo/src/CaloCellCollector.cxx index 21fad6c083c..40ab7f69d09 100644 --- a/Reconstruction/RecoTools/TrackToCalo/src/CaloCellCollector.cxx +++ b/Reconstruction/RecoTools/TrackToCalo/src/CaloCellCollector.cxx @@ -1,11 +1,11 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "TrackToCalo/CaloCellCollector.h" #include "TrkCaloExtension/CaloExtensionHelpers.h" -#include "CaloInterface/ICaloNoiseTool.h" +#include "CaloConditions/CaloNoise.h" #include "CaloUtils/CaloClusterStoreHelper.h" #include "CaloEvent/CaloCellContainer.h" @@ -260,16 +260,9 @@ Rec::CaloCellCollector::collectCells( const Trk::CaloExtension& extension, void Rec::CaloCellCollector::collectEtCore( const xAOD::CaloCluster& clus, std::vector<float>& etcore, - const ToolHandle <ICaloNoiseTool>& caloNoiseTool, - bool applyNoiseCut, + const CaloNoise* caloNoise, float sigmaNoiseCut) const { - // FIXME: const_cast - ICaloNoiseTool* caloNoiseTool_nc = nullptr; - if (!caloNoiseTool.empty()) { - const ICaloNoiseTool* caloNoiseTool_c = &*caloNoiseTool; - caloNoiseTool_nc = const_cast<ICaloNoiseTool*> (caloNoiseTool_c); - } // Collect the cells in the core for a muon // Collect etCore for the different samples @@ -307,15 +300,10 @@ Rec::CaloCellCollector::collectEtCore( const xAOD::CaloCluster& clus, } // Check if cell passes the noise threshold of 3.4sigma if (m_doDebug && addCell) { - if( !caloNoiseTool.empty() ) std::cout << " cell E,3.4*noise: " << cell->energy() << "/" << 3.4*caloNoiseTool_nc->getNoise(cell); - else std::cout << " cell E, NO CaloNoiseTool available: " << cell->energy() << "/ - "; + if( caloNoise != nullptr ) std::cout << " cell E,3.4*noise: " << cell->energy() << "/" << 3.4*caloNoise->getNoise(cell->ID(), cell->gain()); + else std::cout << " cell E, NO CaloNoise available: " << cell->energy() << "/ - "; } - if (applyNoiseCut && caloNoiseTool.empty() ){ - std::cout << "ERROR : Configured to apply calo noise cut, however no CaloNoiseTool available.\n " - << "ERROR : Changing configuration to NOT apply calo noise cut!" << std::endl; - applyNoiseCut = false; - } - if (applyNoiseCut && addCell && cell->energy() < sigmaNoiseCut*caloNoiseTool_nc->getNoise(cell)) { + if (caloNoise && addCell && cell->energy() < sigmaNoiseCut*caloNoise->getNoise(cell->ID(), cell->gain())) { addCell = false; } // sum of et, defined by cell E, and muon track eta diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Muon/MuonSetup.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Muon/MuonSetup.py index d5b0a2f752a..b3742e96874 100644 --- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Muon/MuonSetup.py +++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Muon/MuonSetup.py @@ -650,7 +650,7 @@ def muEFCBRecoSequence( RoIs, name ): theMuonCandidateAlgCB=CfgMgr.MuonCombinedMuonCandidateAlg("MuonCandidateAlgCB_"+name,MuonCandidateTool=theCandidateToolCB,MuonCandidateLocation="MuonCandidates", MSOnlyExtrapolatedTrackLocation="MSOnlyMuonTracksForCB") #Create xAOD Muons - thecreatortoolCB= getPublicToolClone("MuonCreatorTool_triggerCB_"+name, "MuonCreatorTool", ScatteringAngleTool="", CaloMaterialProvider='TMEF_TrkMaterialProviderTool', MuonSelectionTool="", FillTimingInformation=False, DoCaloNoiseCut=False, UseCaloCells=False) + thecreatortoolCB= getPublicToolClone("MuonCreatorTool_triggerCB_"+name, "MuonCreatorTool", ScatteringAngleTool="", CaloMaterialProvider='TMEF_TrkMaterialProviderTool', MuonSelectionTool="", FillTimingInformation=False, UseCaloCells=False) themuoncbcreatoralg = CfgMgr.MuonCreatorAlg("MuonCreatorAlgCB_"+name, MuonCandidateLocation="CombinedMuonCandidates") themuoncbcreatoralg.MuonCreatorTool=thecreatortoolCB -- GitLab