From 2c546b94582ede83b28c7edd277c70e08313258e Mon Sep 17 00:00:00 2001 From: Niels Van Eldik <niels.van.eldik@cern.ch> Date: Tue, 27 Jan 2015 16:32:44 +0100 Subject: [PATCH] src/CaloMuonLikelihoodTool.cxx (getLHR): fix buggy if statement (CaloTrkMuIdTools-00-15-02) * src/CaloMuonLikelihoodTool.cxx (getLHR): fix buggy if statement * tag CaloTrkMuIdTools-00-15-02 2015-01-24 RD Schaffer <R.D.Schaffer@cern.ch> * src/CaloMuonLikelihoodTool.cxx (getLHR): return 0 if no CaloClusterContainer * tag CaloTrkMuIdTools-00-15-01 2015-01-20 Niels van Eldik * add code to allow usage of the tagger in the trigger * tag CaloTrkMuIdTools-00-15-00 2014-12-11 Sue Cheatham * CaloTrkMuIdTools_jobOptions.py Do not try to read ntuples when running online * tag CaloTrkMuIdTools-00-14-03 --- .../CaloTrkMuIdTools/CaloMuonLikelihoodTool.h | 3 ++- .../CaloTrkMuIdTools/TrackDepositInCaloTool.h | 5 +++- .../CaloTrkMuIdTools/cmt/requirements | 2 +- .../share/CaloTrkMuIdTools_jobOptions.py | 25 ++++++++++++------- .../src/CaloMuonLikelihoodTool.cxx | 15 ++++++----- .../src/TrackDepositInCaloTool.cxx | 19 ++++++++------ 6 files changed, 44 insertions(+), 25 deletions(-) diff --git a/Reconstruction/MuonIdentification/CaloTrkMuIdTools/CaloTrkMuIdTools/CaloMuonLikelihoodTool.h b/Reconstruction/MuonIdentification/CaloTrkMuIdTools/CaloTrkMuIdTools/CaloMuonLikelihoodTool.h index 4f9aea8c4c2..12baf5ecddd 100644 --- a/Reconstruction/MuonIdentification/CaloTrkMuIdTools/CaloTrkMuIdTools/CaloMuonLikelihoodTool.h +++ b/Reconstruction/MuonIdentification/CaloTrkMuIdTools/CaloTrkMuIdTools/CaloMuonLikelihoodTool.h @@ -13,6 +13,7 @@ #include "GaudiKernel/ToolHandle.h" #include "GaudiKernel/ServiceHandle.h" #include "StoreGate/StoreGateSvc.h" +#include "CaloEvent/CaloClusterContainer.h" #include <string> @@ -35,7 +36,7 @@ public: virtual StatusCode initialize(); virtual StatusCode finalize(); - double getLHR(const Trk::TrackParameters* trkpar, const double dR_CUT=0.3) const; + double getLHR(const Trk::TrackParameters* trkpar, const xAOD::CaloClusterContainer* ClusCollection=nullptr, const double dR_CUT=0.3) const; double getLHR(const xAOD::CaloClusterContainer* ClusCollection, const double eta_trk, const double p_trk, const double eta_trkAtCalo, const double phi_trkAtCalo, const double dR_CUT=0.3) const; private: diff --git a/Reconstruction/MuonIdentification/CaloTrkMuIdTools/CaloTrkMuIdTools/TrackDepositInCaloTool.h b/Reconstruction/MuonIdentification/CaloTrkMuIdTools/CaloTrkMuIdTools/TrackDepositInCaloTool.h index f16a2f674e5..baf00c10f1a 100755 --- a/Reconstruction/MuonIdentification/CaloTrkMuIdTools/CaloTrkMuIdTools/TrackDepositInCaloTool.h +++ b/Reconstruction/MuonIdentification/CaloTrkMuIdTools/CaloTrkMuIdTools/TrackDepositInCaloTool.h @@ -16,6 +16,9 @@ #include "GaudiKernel/ToolHandle.h" #include "GaudiKernel/ITHistSvc.h" +// --- Athena --- +#include "CaloEvent/CaloCellContainer.h" + // --- STL --- #include <utility> #include <vector> @@ -62,7 +65,7 @@ class TrackDepositInCaloTool: public AthAlgTool, virtual public ITrackDepositInC @param deltaR Unused parameter. Kept for backward compatibility. @param inCell Unused parameter. Kept for backward compatibility. */ - std::vector<DepositInCalo> getDeposits(const Trk::TrackParameters* par) const; + std::vector<DepositInCalo> getDeposits(const Trk::TrackParameters* par, const CaloCellContainer* caloCellCont = nullptr) const; std::vector<DepositInCalo> deposits(const Trk::TrackParameters *par, const double deltaR=0.3, const bool inCell= true) const; /** diff --git a/Reconstruction/MuonIdentification/CaloTrkMuIdTools/cmt/requirements b/Reconstruction/MuonIdentification/CaloTrkMuIdTools/cmt/requirements index 644e7926eb4..499f9f47324 100755 --- a/Reconstruction/MuonIdentification/CaloTrkMuIdTools/cmt/requirements +++ b/Reconstruction/MuonIdentification/CaloTrkMuIdTools/cmt/requirements @@ -13,6 +13,7 @@ use ICaloTrkMuIdTools ICaloTrkMuIdTools-* Reconstruction/MuonI use CaloInterface CaloInterface-* Calorimeter use CaloTrackingGeometry CaloTrackingGeometry-* Calorimeter +use CaloEvent CaloEvent-* Calorimeter private use AtlasCLHEP AtlasCLHEP-* External @@ -24,7 +25,6 @@ use TrkEventPrimitives TrkEventPrimitives-* Tracking/TrkEvent use TrkSurfaces TrkSurfaces-* Tracking/TrkDetDescr use CaloIdentifier CaloIdentifier-* Calorimeter -use CaloEvent CaloEvent-* Calorimeter use xAODCaloEvent xAODCaloEvent-* Event/xAOD use CaloDetDescr CaloDetDescr-* Calorimeter use TileDetDescr TileDetDescr-* TileCalorimeter diff --git a/Reconstruction/MuonIdentification/CaloTrkMuIdTools/share/CaloTrkMuIdTools_jobOptions.py b/Reconstruction/MuonIdentification/CaloTrkMuIdTools/share/CaloTrkMuIdTools_jobOptions.py index 271a49aa8e7..3b8cb7c152b 100755 --- a/Reconstruction/MuonIdentification/CaloTrkMuIdTools/share/CaloTrkMuIdTools_jobOptions.py +++ b/Reconstruction/MuonIdentification/CaloTrkMuIdTools/share/CaloTrkMuIdTools_jobOptions.py @@ -3,6 +3,10 @@ ############################################################################### include.block("CaloTrkMuIdTools/CaloTrkMuIdTools_jobOptions.py") + +###logfile +from AthenaCommon.Logging import log + ############################################################################### ## Helper function for defining THistSvc inputs ############################################################################### @@ -58,15 +62,18 @@ from AthenaCommon.AppMgr import ServiceMgr if not hasattr(ServiceMgr, 'THistSvc'): ServiceMgr += CfgMgr.THistSvc() -ServiceMgr.THistSvc.Input += defineCaloLhrPdf("CaloMuonLikelihood.PDF.A0.root"); ### PDFs for barrel region low pT -ServiceMgr.THistSvc.Input += defineCaloLhrPdf("CaloMuonLikelihood.PDF.A1.root"); ### PDFs for barrel region medium pT -ServiceMgr.THistSvc.Input += defineCaloLhrPdf("CaloMuonLikelihood.PDF.A2.root"); ### PDFs for barrel region high pT -ServiceMgr.THistSvc.Input += defineCaloLhrPdf("CaloMuonLikelihood.PDF.B0.root"); ### PDFs for transition region low pT -ServiceMgr.THistSvc.Input += defineCaloLhrPdf("CaloMuonLikelihood.PDF.B1.root"); ### PDFs for transition region medium pT -ServiceMgr.THistSvc.Input += defineCaloLhrPdf("CaloMuonLikelihood.PDF.B2.root"); ### PDFs for transition region high pT -ServiceMgr.THistSvc.Input += defineCaloLhrPdf("CaloMuonLikelihood.PDF.C0.root"); ### PDFs for endcap region low pT -ServiceMgr.THistSvc.Input += defineCaloLhrPdf("CaloMuonLikelihood.PDF.C1.root"); ### PDFs for endcap region medium pT -ServiceMgr.THistSvc.Input += defineCaloLhrPdf("CaloMuonLikelihood.PDF.C2.root"); ### PDFs for endcap region high pT +from AthenaCommon.AthenaCommonFlags import athenaCommonFlags +if athenaCommonFlags.isOnline == False: + log.error('THistSvc.Input = %s. Reading ntuples CaloTrkMuIdTools.' % ServiceMgr.THistSvc.Input) + ServiceMgr.THistSvc.Input += defineCaloLhrPdf("CaloMuonLikelihood.PDF.A0.root"); ### PDFs for barrel region low pT + ServiceMgr.THistSvc.Input += defineCaloLhrPdf("CaloMuonLikelihood.PDF.A1.root"); ### PDFs for barrel region medium pT + ServiceMgr.THistSvc.Input += defineCaloLhrPdf("CaloMuonLikelihood.PDF.A2.root"); ### PDFs for barrel region high pT + ServiceMgr.THistSvc.Input += defineCaloLhrPdf("CaloMuonLikelihood.PDF.B0.root"); ### PDFs for transition region low pT + ServiceMgr.THistSvc.Input += defineCaloLhrPdf("CaloMuonLikelihood.PDF.B1.root"); ### PDFs for transition region medium pT + ServiceMgr.THistSvc.Input += defineCaloLhrPdf("CaloMuonLikelihood.PDF.B2.root"); ### PDFs for transition region high pT + ServiceMgr.THistSvc.Input += defineCaloLhrPdf("CaloMuonLikelihood.PDF.C0.root"); ### PDFs for endcap region low pT + ServiceMgr.THistSvc.Input += defineCaloLhrPdf("CaloMuonLikelihood.PDF.C1.root"); ### PDFs for endcap region medium pT + ServiceMgr.THistSvc.Input += defineCaloLhrPdf("CaloMuonLikelihood.PDF.C2.root"); ### PDFs for endcap region high pT ### Configure TrackEnergyInCaloTool ### from CaloTrkMuIdTools.CaloTrkMuIdToolsConf import TrackEnergyInCaloTool as ConfiguredTrackEnergyInCaloTool diff --git a/Reconstruction/MuonIdentification/CaloTrkMuIdTools/src/CaloMuonLikelihoodTool.cxx b/Reconstruction/MuonIdentification/CaloTrkMuIdTools/src/CaloMuonLikelihoodTool.cxx index 4c11a3b878b..14dee254bbc 100644 --- a/Reconstruction/MuonIdentification/CaloTrkMuIdTools/src/CaloMuonLikelihoodTool.cxx +++ b/Reconstruction/MuonIdentification/CaloTrkMuIdTools/src/CaloMuonLikelihoodTool.cxx @@ -282,7 +282,7 @@ StatusCode CaloMuonLikelihoodTool::retrieveHistograms() { /////////////////////////////////////////////////////////////////////////////// // CaloMuonLikelihoodTool::getLHR /////////////////////////////////////////////////////////////////////////////// -double CaloMuonLikelihoodTool::getLHR( const Trk::TrackParameters* trkpar, const double dR_CUT ) const { +double CaloMuonLikelihoodTool::getLHR( const Trk::TrackParameters* trkpar, const xAOD::CaloClusterContainer* ClusContainer, const double dR_CUT ) const { ATH_MSG_DEBUG("in CaloMuonLikelihoodTool::getLHR()"); Trk::ParticleHypothesis particleHypo = Trk::muon; @@ -317,13 +317,16 @@ double CaloMuonLikelihoodTool::getLHR( const Trk::TrackParameters* trkpar, const } - const xAOD::CaloClusterContainer* m_clusCont; - if ( evtStore()->retrieve(m_clusCont, m_caloClusterContainerName).isFailure() ) { - ATH_MSG_WARNING("Could not retrieve CaloClusterContainer with key <" << m_caloClusterContainerName << " >"); - return 0; + const xAOD::CaloClusterContainer* clusCont = ClusContainer; + if(clusCont == nullptr) { + if ( evtStore()->retrieve(clusCont, m_caloClusterContainerName).isFailure() ) { + ATH_MSG_WARNING("Could not retrieve CaloClusterContainer with key <" << m_caloClusterContainerName << " >"); + return 0; + } } + if(clusCont == nullptr) return 0; - double LR = getLHR( m_clusCont, eta_trk, p_trk, eta_trkAtCalo, phi_trkAtCalo, dR_CUT); + double LR = getLHR( clusCont, eta_trk, p_trk, eta_trkAtCalo, phi_trkAtCalo, dR_CUT); return LR; } diff --git a/Reconstruction/MuonIdentification/CaloTrkMuIdTools/src/TrackDepositInCaloTool.cxx b/Reconstruction/MuonIdentification/CaloTrkMuIdTools/src/TrackDepositInCaloTool.cxx index 86eaee0095d..52129f3f5b3 100755 --- a/Reconstruction/MuonIdentification/CaloTrkMuIdTools/src/TrackDepositInCaloTool.cxx +++ b/Reconstruction/MuonIdentification/CaloTrkMuIdTools/src/TrackDepositInCaloTool.cxx @@ -116,7 +116,7 @@ StatusCode TrackDepositInCaloTool::finalize() { /////////////////////////////////////////////////////////////////////////////// // getDeposits /////////////////////////////////////////////////////////////////////////////// -std::vector<DepositInCalo> TrackDepositInCaloTool::getDeposits(const Trk::TrackParameters* par) const { +std::vector<DepositInCalo> TrackDepositInCaloTool::getDeposits(const Trk::TrackParameters* par, const CaloCellContainer* caloCellCont) const { ATH_MSG_DEBUG("In TrackDepositInCaloTool::getDeposits()"); std::vector<DepositInCalo> result; @@ -126,13 +126,18 @@ std::vector<DepositInCalo> TrackDepositInCaloTool::getDeposits(const Trk::TrackP return result; } // --- Get the CaloCellContainer from storegate every event --- - if ( evtStore()->retrieve(m_cellContainer, m_cellContainerName).isFailure() ) { - ATH_MSG_WARNING("Could not retrieve CaloCellContainer, key <" << m_cellContainerName << ">"); - return result; + if(caloCellCont == nullptr) { + if ( evtStore()->retrieve(m_cellContainer, m_cellContainerName).isFailure() ) { + ATH_MSG_WARNING("Could not retrieve CaloCellContainer, key <" << m_cellContainerName << ">"); + return result; + } + if (!m_cellContainer) { + ATH_MSG_WARNING("Cell container retrieved, but pointer is 0."); + return result; + } } - if (!m_cellContainer) { - ATH_MSG_WARNING("Cell container retrieved, but pointer is 0."); - return result; + else { + m_cellContainer = caloCellCont; } const Trk::ParticleHypothesis muonHypo = Trk::muon; -- GitLab