diff --git a/Reconstruction/tauRec/src/TauProcessorAlg.cxx b/Reconstruction/tauRec/src/TauProcessorAlg.cxx index 497a6eb9782a4b42b95e56cbb2b50d7aaf8576e0..96fea64f6d4ae3da1e7ec3dd045b89dc2e181408 100644 --- a/Reconstruction/tauRec/src/TauProcessorAlg.cxx +++ b/Reconstruction/tauRec/src/TauProcessorAlg.cxx @@ -129,72 +129,48 @@ StatusCode TauProcessorAlg::finalize() { StatusCode TauProcessorAlg::execute() { const EventContext& ctx = Gaudi::Hive::currentContext(); - //------------------------------------------------------------------------- - // Create and Record containers - //------------------------------------------------------------------------- - auto pContainer = std::make_unique<xAOD::TauJetContainer>(); - auto pAuxContainer = std::make_unique<xAOD::TauJetAuxContainer>(); - pContainer->setStore( pAuxContainer.get() ); - - auto pTauTrackCont = std::make_unique<xAOD::TauTrackContainer>(); - auto pTauTrackAuxCont = std::make_unique<xAOD::TauTrackAuxContainer>(); - pTauTrackCont->setStore( pTauTrackAuxCont.get() ); - - // Declare write handles - SG::WriteHandle<xAOD::TauJetContainer> tauHandle( m_tauOutputContainer, ctx ); - SG::WriteHandle<xAOD::TauTrackContainer> tauTrackHandle( m_tauTrackOutputContainer, ctx ); - - //--------------------------------------------------------------------- - // Retrieve seed Container from TDS, return `failure if no - // existing - //--------------------------------------------------------------------- - SG::ReadHandle<xAOD::JetContainer> jetHandle( m_jetInputContainer, ctx ); - if (!jetHandle.isValid()) { - ATH_MSG_ERROR ("Could not retrieve HiveDataObj with key " << jetHandle.key()); - return StatusCode::FAILURE; - } - const xAOD::JetContainer *pSeedContainer = 0; - pSeedContainer = jetHandle.cptr(); - - // The calo cluster containter must be registered to storegate here, in order to set links in shot finder tool - // Will still allow changes to the container within this algorithm - SG::WriteHandle<xAOD::CaloClusterContainer> tauShotClusHandle( m_tauShotClusOutputContainer, ctx ); - xAOD::CaloClusterContainer* tauShotClusContainer = new xAOD::CaloClusterContainer(); - xAOD::CaloClusterAuxContainer* tauShotClusAuxStore = new xAOD::CaloClusterAuxContainer(); - tauShotClusContainer->setStore(tauShotClusAuxStore); - ATH_MSG_DEBUG(" write: " << tauShotClusHandle.key() << " = " << "..." ); - ATH_CHECK(tauShotClusHandle.record(std::unique_ptr<xAOD::CaloClusterContainer>{tauShotClusContainer}, std::unique_ptr<xAOD::CaloClusterAuxContainer>{tauShotClusAuxStore})); - - SG::WriteHandle<xAOD::PFOContainer> tauShotPFOHandle( m_tauShotPFOOutputContainer, ctx ); - xAOD::PFOContainer* tauShotPFOContainer = new xAOD::PFOContainer(); - xAOD::PFOAuxContainer* tauShotPFOAuxStore = new xAOD::PFOAuxContainer(); - tauShotPFOContainer->setStore(tauShotPFOAuxStore); - ATH_MSG_DEBUG(" write: " << tauShotPFOHandle.key() << " = " << "..." ); - ATH_CHECK(tauShotPFOHandle.record(std::unique_ptr<xAOD::PFOContainer>{tauShotPFOContainer}, std::unique_ptr<xAOD::PFOAuxContainer>{tauShotPFOAuxStore})); - - SG::WriteHandle<CaloCellContainer> tauPi0CellHandle( m_tauPi0CellOutputContainer, ctx ); - CaloCellContainer* Pi0CellContainer = new CaloCellContainer(); - ATH_MSG_DEBUG(" write: " << tauPi0CellHandle.key() << " = " << "..." ); - ATH_CHECK(tauPi0CellHandle.record(std::unique_ptr<CaloCellContainer>(Pi0CellContainer))); - - //--------------------------------------------------------------------- - // Loop over seeds - //--------------------------------------------------------------------- - xAOD::JetContainer::const_iterator itS = pSeedContainer->begin(); - xAOD::JetContainer::const_iterator itSE = pSeedContainer->end(); - - ATH_MSG_VERBOSE("Number of seeds in the container: " << pSeedContainer->size()); + /// record output containers + SG::WriteHandle<xAOD::TauJetContainer> tauHandle( m_tauOutputContainer, ctx ); + ATH_CHECK(tauHandle.record(std::make_unique<xAOD::TauJetContainer>(), std::make_unique<xAOD::TauJetAuxContainer>())); + xAOD::TauJetContainer* pContainer = tauHandle.ptr(); + + SG::WriteHandle<xAOD::TauTrackContainer> tauTrackHandle( m_tauTrackOutputContainer, ctx ); + ATH_CHECK(tauTrackHandle.record(std::make_unique<xAOD::TauTrackContainer>(), std::make_unique<xAOD::TauTrackAuxContainer>())); + xAOD::TauTrackContainer* pTauTrackCont = tauTrackHandle.ptr(); + + SG::WriteHandle<xAOD::CaloClusterContainer> tauShotClusHandle( m_tauShotClusOutputContainer, ctx ); + ATH_CHECK(tauShotClusHandle.record(std::make_unique<xAOD::CaloClusterContainer>(), std::make_unique<xAOD::CaloClusterAuxContainer>())); + xAOD::CaloClusterContainer* tauShotClusContainer = tauShotClusHandle.ptr(); + + SG::WriteHandle<xAOD::PFOContainer> tauShotPFOHandle( m_tauShotPFOOutputContainer, ctx ); + ATH_CHECK(tauShotPFOHandle.record(std::make_unique<xAOD::PFOContainer>(), std::make_unique<xAOD::PFOAuxContainer>())); + xAOD::PFOContainer* tauShotPFOContainer = tauShotPFOHandle.ptr(); + + SG::WriteHandle<CaloCellContainer> tauPi0CellHandle( m_tauPi0CellOutputContainer, ctx ); + ATH_CHECK(tauPi0CellHandle.record(std::make_unique<CaloCellContainer>())); + CaloCellContainer* Pi0CellContainer = tauPi0CellHandle.ptr(); + + /// retrieve the input jet seed container + SG::ReadHandle<xAOD::JetContainer> jetHandle( m_jetInputContainer, ctx ); + if (!jetHandle.isValid()) { + ATH_MSG_ERROR ("Could not retrieve HiveDataObj with key " << jetHandle.key()); + return StatusCode::FAILURE; + } + const xAOD::JetContainer *pSeedContainer = jetHandle.cptr(); + + /// Initialize the cell map per event, used to avoid dumplicate cell in TauPi0CreateROI + IdentifierHash hashMax = m_cellID->calo_cell_hash_max(); + ATH_MSG_DEBUG("CaloCell Hash Max: " << hashMax); + std::vector<CaloCell*> addedCellsMap; + addedCellsMap.resize(hashMax,NULL); + + //--------------------------------------------------------------------- + // Loop over seeds + //--------------------------------------------------------------------- + ATH_MSG_VERBOSE("Number of seeds in the container: " << pSeedContainer->size()); - /// Initialize the cell map per event, used to avoid dumplicate cell in TauPi0CreateROI - IdentifierHash hashMax = m_cellID->calo_cell_hash_max(); - ATH_MSG_DEBUG("CaloCell Hash Max: " << hashMax); - std::vector<CaloCell*> addedCellsMap; - addedCellsMap.resize(hashMax,NULL); - - for (; itS != itSE; ++itS) { - - const xAOD::Jet *pSeed = (*itS); - ATH_MSG_VERBOSE("Seeds eta:" << pSeed->eta() << ", pt:" << pSeed->pt()); + for (const xAOD::Jet* pSeed : *pSeedContainer) { + ATH_MSG_VERBOSE("Seeds eta:" << pSeed->eta() << ", pt:" << pSeed->pt()); if (fabs(pSeed->eta()) > m_maxEta) { ATH_MSG_VERBOSE("--> Seed rejected, eta out of range!"); @@ -214,7 +190,7 @@ StatusCode TauProcessorAlg::execute() { pTau->setJet(pSeedContainer, pSeed); // This sets one track and link. Need to have at least 1 track linked to retrieve track container - setEmptyTauTrack(pTau, pTauTrackCont.get()); + setEmptyTauTrack(pTau, pTauTrackCont); //----------------------------------------------------------------- // Loop stops when Failure indicated by one of the tools @@ -260,22 +236,15 @@ StatusCode TauProcessorAlg::execute() { // Check this is needed for the cell container? // symlink as INavigable4MomentumCollection (as in CaloRec/CaloCellMaker) ATH_CHECK(evtStore()->symLink(Pi0CellContainer, static_cast<INavigable4MomentumCollection*> (0))); - + // sort the cell container by hash ATH_CHECK( m_cellMakerTool->process(static_cast<CaloCellContainer*> (Pi0CellContainer), ctx) ); ATH_MSG_VERBOSE("The tau candidate container has been modified"); - // Write the completed tau and track containers - ATH_MSG_DEBUG(" write: " << tauHandle.key() << " = " << "..." ); - ATH_CHECK(tauHandle.record( std::move(pContainer), std::move(pAuxContainer) )); - ATH_MSG_DEBUG(" write: " << tauTrackHandle.key() << " = " << "..." ); - ATH_CHECK(tauTrackHandle.record( std::move(pTauTrackCont), std::move(pTauTrackAuxCont) )); - return StatusCode::SUCCESS; } - void TauProcessorAlg::setEmptyTauTrack(xAOD::TauJet* &pTau, xAOD::TauTrackContainer* tauTrackContainer) { @@ -288,4 +257,3 @@ void TauProcessorAlg::setEmptyTauTrack(xAOD::TauJet* &pTau, linkToTauTrack.toContainedElement(*tauTrackContainer, pTrack); pTau->addTauTrackLink(linkToTauTrack); } - diff --git a/Reconstruction/tauRec/src/TauRunnerAlg.cxx b/Reconstruction/tauRec/src/TauRunnerAlg.cxx index cbc5a21d9f0632ce23e000ebfe017a34ff744c65..cbaf7e6aedb0eb3a193951329679ac42c894e8f6 100644 --- a/Reconstruction/tauRec/src/TauRunnerAlg.cxx +++ b/Reconstruction/tauRec/src/TauRunnerAlg.cxx @@ -21,7 +21,6 @@ #include "StoreGate/ReadHandle.h" #include "StoreGate/WriteHandle.h" - //----------------------------------------------------------------------------- // Constructor //----------------------------------------------------------------------------- @@ -121,91 +120,65 @@ StatusCode TauRunnerAlg::finalize() { //----------------------------------------------------------------------------- StatusCode TauRunnerAlg::execute() { - // write neutral PFO container - xAOD::PFOContainer* neutralPFOContainer = new xAOD::PFOContainer(); - xAOD::PFOAuxContainer* neutralPFOAuxStore = new xAOD::PFOAuxContainer(); - neutralPFOContainer->setStore(neutralPFOAuxStore); - SG::WriteHandle<xAOD::PFOContainer> neutralPFOHandle( m_neutralPFOOutputContainer ); - ATH_MSG_DEBUG(" write: " << neutralPFOHandle.key() << " = " << "..." ); - ATH_CHECK(neutralPFOHandle.record(std::unique_ptr<xAOD::PFOContainer>{neutralPFOContainer}, std::unique_ptr<xAOD::PFOAuxContainer>{neutralPFOAuxStore})); - - // write hadronic cluster PFO container - xAOD::PFOContainer* hadronicClusterPFOContainer = new xAOD::PFOContainer(); - xAOD::PFOAuxContainer* hadronicClusterPFOAuxStore = new xAOD::PFOAuxContainer(); - hadronicClusterPFOContainer->setStore(hadronicClusterPFOAuxStore); - SG::WriteHandle<xAOD::PFOContainer> hadronicPFOHandle( m_hadronicPFOOutputContainer ); - ATH_MSG_DEBUG(" write: " << hadronicPFOHandle.key() << " = " << "..." ); - ATH_CHECK(hadronicPFOHandle.record(std::unique_ptr<xAOD::PFOContainer>{hadronicClusterPFOContainer}, std::unique_ptr<xAOD::PFOAuxContainer>{hadronicClusterPFOAuxStore})); - - // write pi0 calo clusters - xAOD::CaloClusterContainer* pi0CaloClusterContainer = new xAOD::CaloClusterContainer(); - xAOD::CaloClusterAuxContainer* pi0CaloClusterAuxContainer = new xAOD::CaloClusterAuxContainer(); - pi0CaloClusterContainer->setStore(pi0CaloClusterAuxContainer); - SG::WriteHandle<xAOD::CaloClusterContainer> pi0CaloClusHandle( m_pi0ClusterOutputContainer ); - ATH_MSG_DEBUG(" write: " << pi0CaloClusHandle.key() << " = " << "..." ); - ATH_CHECK(pi0CaloClusHandle.record(std::unique_ptr<xAOD::CaloClusterContainer>{pi0CaloClusterContainer}, std::unique_ptr<xAOD::CaloClusterAuxContainer>{pi0CaloClusterAuxContainer})); - - // write secondary vertices - xAOD::VertexContainer* pSecVtxContainer = new xAOD::VertexContainer(); - xAOD::VertexAuxContainer* pSecVtxAuxContainer = new xAOD::VertexAuxContainer(); - pSecVtxContainer->setStore( pSecVtxAuxContainer ); - SG::WriteHandle<xAOD::VertexContainer> vertOutHandle( m_vertexOutputContainer ); - ATH_MSG_DEBUG(" write: " << vertOutHandle.key() << " = " << "..." ); - ATH_CHECK(vertOutHandle.record(std::unique_ptr<xAOD::VertexContainer>{pSecVtxContainer}, std::unique_ptr<xAOD::VertexAuxContainer>{pSecVtxAuxContainer})); - - // write charged PFO container - xAOD::PFOContainer* chargedPFOContainer = new xAOD::PFOContainer(); - xAOD::PFOAuxContainer* chargedPFOAuxStore = new xAOD::PFOAuxContainer(); - chargedPFOContainer->setStore(chargedPFOAuxStore); - SG::WriteHandle<xAOD::PFOContainer> chargedPFOHandle( m_chargedPFOOutputContainer ); - ATH_MSG_DEBUG(" write: " << chargedPFOHandle.key() << " = " << "..." ); - ATH_CHECK(chargedPFOHandle.record(std::unique_ptr<xAOD::PFOContainer>{chargedPFOContainer}, std::unique_ptr<xAOD::PFOAuxContainer>{chargedPFOAuxStore})); - - // write pi0 container - xAOD::ParticleContainer* pi0Container = new xAOD::ParticleContainer(); - xAOD::ParticleAuxContainer* pi0AuxStore = new xAOD::ParticleAuxContainer(); - pi0Container->setStore(pi0AuxStore); - SG::WriteHandle<xAOD::ParticleContainer> pi0Handle( m_pi0Container ); - ATH_MSG_DEBUG(" write: " << pi0Handle.key() << " = " << "..." ); - ATH_CHECK(pi0Handle.record(std::unique_ptr<xAOD::ParticleContainer>{pi0Container}, std::unique_ptr<xAOD::ParticleAuxContainer>{pi0AuxStore})); + // write neutral PFO container + SG::WriteHandle<xAOD::PFOContainer> neutralPFOHandle( m_neutralPFOOutputContainer ); + ATH_CHECK(neutralPFOHandle.record(std::make_unique<xAOD::PFOContainer>(), std::make_unique<xAOD::PFOAuxContainer>())); + xAOD::PFOContainer* neutralPFOContainer = neutralPFOHandle.ptr(); + + // write hadronic cluster PFO container + SG::WriteHandle<xAOD::PFOContainer> hadronicPFOHandle( m_hadronicPFOOutputContainer ); + ATH_CHECK(hadronicPFOHandle.record(std::make_unique<xAOD::PFOContainer>(), std::make_unique<xAOD::PFOAuxContainer>())); + xAOD::PFOContainer* hadronicClusterPFOContainer = hadronicPFOHandle.ptr(); + + // write pi0 calo clusters + SG::WriteHandle<xAOD::CaloClusterContainer> pi0CaloClusHandle( m_pi0ClusterOutputContainer ); + ATH_CHECK(pi0CaloClusHandle.record(std::make_unique<xAOD::CaloClusterContainer>(), std::make_unique<xAOD::CaloClusterAuxContainer>())); + xAOD::CaloClusterContainer* pi0CaloClusterContainer = pi0CaloClusHandle.ptr(); + + // write secondary vertices + SG::WriteHandle<xAOD::VertexContainer> vertOutHandle( m_vertexOutputContainer ); + ATH_CHECK(vertOutHandle.record(std::make_unique<xAOD::VertexContainer>(), std::make_unique<xAOD::VertexAuxContainer>())); + xAOD::VertexContainer* pSecVtxContainer = vertOutHandle.ptr(); + + // write charged PFO container + SG::WriteHandle<xAOD::PFOContainer> chargedPFOHandle( m_chargedPFOOutputContainer ); + ATH_CHECK(chargedPFOHandle.record(std::make_unique<xAOD::PFOContainer>(), std::make_unique<xAOD::PFOAuxContainer>())); + xAOD::PFOContainer* chargedPFOContainer = chargedPFOHandle.ptr(); + + // write pi0 container + SG::WriteHandle<xAOD::ParticleContainer> pi0Handle( m_pi0Container ); + ATH_CHECK(pi0Handle.record(std::make_unique<xAOD::ParticleContainer>(), std::make_unique<xAOD::ParticleAuxContainer>())); + xAOD::ParticleContainer* pi0Container = pi0Handle.ptr(); - // Declare container - const xAOD::TauJetContainer * pTauContainer = 0; - - // Read in temporary tau jets - SG::ReadHandle<xAOD::TauJetContainer> tauInputHandle(m_tauInputContainer); - if (!tauInputHandle.isValid()) { - ATH_MSG_ERROR ("Could not retrieve HiveDataObj with key " << tauInputHandle.key()); - return StatusCode::FAILURE; - } - pTauContainer = tauInputHandle.cptr(); - - // Read the CaloClusterContainer created by the CaloClusterMaker - const xAOD::CaloClusterContainer * pPi0ClusterContainer; + // Read the CaloClusterContainer created by the CaloClusterMaker + SG::ReadHandle<xAOD::CaloClusterContainer> pi0ClusterInHandle( m_pi0ClusterInputContainer ); + if (!pi0ClusterInHandle.isValid()) { + ATH_MSG_ERROR ("Could not retrieve HiveDataObj with key " << pi0ClusterInHandle.key()); + return StatusCode::FAILURE; + } + const xAOD::CaloClusterContainer * pPi0ClusterContainer = pi0ClusterInHandle.cptr(); + + // Read in temporary tau jets + SG::ReadHandle<xAOD::TauJetContainer> tauInputHandle(m_tauInputContainer); + if (!tauInputHandle.isValid()) { + ATH_MSG_ERROR ("Could not retrieve HiveDataObj with key " << tauInputHandle.key()); + return StatusCode::FAILURE; + } + const xAOD::TauJetContainer* pTauContainer = tauInputHandle.cptr(); - SG::ReadHandle<xAOD::CaloClusterContainer> pi0ClusterInHandle( m_pi0ClusterInputContainer ); - if (!pi0ClusterInHandle.isValid()) { - ATH_MSG_ERROR ("Could not retrieve HiveDataObj with key " << pi0ClusterInHandle.key()); - return StatusCode::FAILURE; - } - pPi0ClusterContainer = pi0ClusterInHandle.cptr(); - - // Make new container which is deep copy of that - xAOD::TauJetContainer* newTauCon = 0; - xAOD::TauJetAuxContainer* newTauAuxCon = 0; - xAOD::TauJet* tau(0); - // See function in header file - ATH_CHECK(deepCopy(newTauCon, newTauAuxCon, tau, pTauContainer)); - // Write final taujets container - SG::WriteHandle<xAOD::TauJetContainer> outputTauHandle(m_tauOutputContainer); - ATH_CHECK( outputTauHandle.record(std::unique_ptr<xAOD::TauJetContainer>(newTauCon), - std::unique_ptr<xAOD::TauJetAuxContainer>(newTauAuxCon)) ); + // Write the output tau jets, which is a deep copy of the input ones + SG::WriteHandle<xAOD::TauJetContainer> outputTauHandle(m_tauOutputContainer); + ATH_CHECK(outputTauHandle.record(std::make_unique<xAOD::TauJetContainer>(), std::make_unique<xAOD::TauJetAuxContainer>())); + xAOD::TauJetContainer* newTauCon = outputTauHandle.ptr(); + for (const xAOD::TauJet* tau : *pTauContainer) { + xAOD::TauJet* newTau = new xAOD::TauJet(); + newTauCon->push_back(newTau); + *newTau = *tau; + } + // iterate over the copy - xAOD::TauJetContainer::iterator itTau = newTauCon->begin(); - xAOD::TauJetContainer::iterator itTauE = newTauCon->end(); - for (; itTau != itTauE; ++itTau) { - xAOD::TauJet* pTau = (*itTau); + for (xAOD::TauJet* pTau : *newTauCon) { //----------------------------------------------------------------- // Loop stops when Failure indicated by one of the tools //----------------------------------------------------------------- diff --git a/Reconstruction/tauRec/tauRec/TauRunnerAlg.h b/Reconstruction/tauRec/tauRec/TauRunnerAlg.h index 172d0581fe63bde2b1bf53dd44259dc3a3ada4cc..3bab5d1d2897b5a951c3da831556d507111a7005 100644 --- a/Reconstruction/tauRec/tauRec/TauRunnerAlg.h +++ b/Reconstruction/tauRec/tauRec/TauRunnerAlg.h @@ -45,9 +45,6 @@ class TauRunnerAlg: public AthAlgorithm virtual StatusCode execute() override; virtual StatusCode finalize() override; - // template for deep copy function - template<class T, class U, class V> StatusCode deepCopy(T*& containerOut, U*& containerStoreOut, const V* dummyContainerType, - const T*& oldContainer); private: ToolHandleArray<ITauToolBase> m_tools{this, "TauRunnerTools", {}, "Tools building taus"}; @@ -66,29 +63,4 @@ class TauRunnerAlg: public AthAlgorithm }; -// Function to perform deep copy on container -template<class T, class U, class V> StatusCode TauRunnerAlg::deepCopy(T*& container, U*& containerStore, const V* /*dummyContainerElementType*/, - const T*& oldContainer){ - - // The new container should be null, check here - if(container==0 && containerStore==0){ - container = new T(); - containerStore = new U(); - container->setStore(containerStore); - } - else{ - ATH_MSG_FATAL("Proviced non-null containters, not initializing please provide null containers: "); - return StatusCode::FAILURE; - } - for( const V* v : *oldContainer ){ - V* newV = new V(); - // Put objects into new container - container->push_back(newV); - // Copy across aux store - *newV = *v; - } - - return StatusCode::SUCCESS; -} - #endif // TAUREC_TAURUNNERALG_H diff --git a/Reconstruction/tauRecTools/Root/CombinedP4FromRecoTaus.cxx b/Reconstruction/tauRecTools/Root/CombinedP4FromRecoTaus.cxx index 4b28b33e1b1eafb4164199ae4be25a50f4ed7839..a12f10197fbd5d2bd540478b64810eefb80c9e6d 100644 --- a/Reconstruction/tauRecTools/Root/CombinedP4FromRecoTaus.cxx +++ b/Reconstruction/tauRecTools/Root/CombinedP4FromRecoTaus.cxx @@ -35,64 +35,82 @@ CombinedP4FromRecoTaus::CombinedP4FromRecoTaus(const std::string& name) : //_____________________________________________________________________________ StatusCode CombinedP4FromRecoTaus::initialize() { + + m_correlationHists.resize(m_modeNames.size()); + + m_meanTGraph_CellBased2PanTau.resize(m_etaBinNames.size()); + m_resTGraph_CellBased2PanTau.resize(m_etaBinNames.size()); + m_meanTGraph_tauRec.resize(m_etaBinNames.size()); + m_resTGraph_tauRec.resize(m_etaBinNames.size()); - m_resTGraph_tauRec = std::vector< std::vector<TGraph*> >(m_etaBinNames.size(), std::vector<TGraph*>(0) ); - m_resTGraph_CellBased2PanTau = std::vector< std::vector<TGraph*> >(m_etaBinNames.size(), std::vector<TGraph*>(0) ); - m_meanTGraph_CellBased2PanTau = std::vector< std::vector<TGraph*> >(m_etaBinNames.size(), std::vector<TGraph*>(0) ); - m_meanTGraph_tauRec = std::vector< std::vector<TGraph*> >(m_etaBinNames.size(), std::vector<TGraph*>(0) ); - - m_correlationHists = std::vector<TH1F*>(0); + for (size_t i=0; i<m_etaBinNames.size(); ++i) { + m_meanTGraph_CellBased2PanTau[i].resize(m_modeNames.size()); + m_resTGraph_CellBased2PanTau[i].resize(m_modeNames.size()); + m_meanTGraph_tauRec[i].resize(m_modeNames.size()); + m_resTGraph_tauRec[i].resize(m_modeNames.size()); + } - std::string calibFilePath = find_file(m_sWeightFileName); - TFile * file = TFile::Open(calibFilePath.c_str(), "READ"); + std::string calibFilePath = find_file(m_sWeightFileName); + std::unique_ptr<TFile> file(TFile::Open(calibFilePath.c_str(), "READ")); m_Nsigma_compatibility=std::make_unique<TF1>("Nsigma_compatibility", "pol1", 0, 500000); // needs to go beyond ~420 where it crosses y=0 m_Nsigma_compatibility->SetParameter(0, 3.809); // derived from fit m_Nsigma_compatibility->SetParameter(1, -9.58/1000000.); // derived from fit - TH1F* histogram(0); + //retrieve correlation histgram + TH1F* histogram(nullptr); std::string histname=""; - TGraph* Graph(0); - std::string Graphname=""; - + //loop over decay modes - for(size_t imode=0;imode < m_modeNames.size();imode++){ + for(size_t imode=0; imode < m_modeNames.size(); ++imode){ ATH_MSG_DEBUG("mode = " << imode); histname="CorrelationCoeff_tauRec_" + m_modeNames[imode]; histogram = dynamic_cast<TH1F*> (file->Get(histname.c_str())); if(histogram){ - m_correlationHists.push_back(histogram); + histogram->SetDirectory(0); + m_correlationHists[imode] = std::unique_ptr<TH1F>(histogram); ATH_MSG_DEBUG("Adding corr hist: "); } + else { + ATH_MSG_FATAL("Failed to get an object with name " << histname); + return StatusCode::FAILURE; + } } + //retrieve mean and resolution graph + TGraph* Graph(nullptr); + std::string Graphname=""; //loop over eta bins - for(size_t ietaBin=0;ietaBin < m_etaBinNames.size(); ietaBin++){ + for(size_t ietaBin=0; ietaBin < m_etaBinNames.size(); ++ietaBin){ //loop over decay modes - for(size_t imode=0;imode < m_modeNames.size();imode++){ + for(size_t imode=0; imode < m_modeNames.size(); ++imode){ ATH_MSG_DEBUG("eta bin = " << ietaBin << " / mode = " << imode ); + // retrieve resolution graph Graphname = "tauRec/Graph_from_ResolutionEt_tauRec_" + m_modeNames[imode] + "_" + m_etaBinNames[ietaBin]; Graph = dynamic_cast<TGraph*> (file->Get(Graphname.c_str())); if(Graph){ - m_resTGraph_tauRec[ietaBin].push_back(Graph); - ATH_MSG_DEBUG("Adding graph: "); - } else { + m_resTGraph_tauRec[ietaBin][imode] = std::unique_ptr<TGraph>(Graph); + ATH_MSG_DEBUG("Adding graph: "); + } + else { ATH_MSG_FATAL("Failed to get an object with name " << Graphname); - return StatusCode::FAILURE; + return StatusCode::FAILURE; } + // retrieve mean graph Graphname = "tauRec/Graph_from_MeanEt_tauRec_" + m_modeNames[imode] + "_" + m_etaBinNames[ietaBin]; Graph = dynamic_cast<TGraph*> (file->Get(Graphname.c_str())); if(Graph) { - m_meanTGraph_tauRec[ietaBin].push_back(Graph); - ATH_MSG_DEBUG("Adding graph: "); - } else { + m_meanTGraph_tauRec[ietaBin][imode] = std::unique_ptr<TGraph>(Graph); + ATH_MSG_DEBUG("Adding graph: "); + } + else { ATH_MSG_FATAL("Failed to get an object with name " << Graphname); return StatusCode::FAILURE; } @@ -100,26 +118,27 @@ StatusCode CombinedP4FromRecoTaus::initialize() { Graphname = "ConstituentEt/Graph_from_ResolutionEt_ConstituentEt_" + m_modeNames[imode] + "_" + m_etaBinNames[ietaBin]; Graph = dynamic_cast<TGraph*> (file->Get(Graphname.c_str())); if(Graph){ - m_resTGraph_CellBased2PanTau[ietaBin].push_back(Graph); - ATH_MSG_DEBUG("Adding graph: "); - } else { - ATH_MSG_FATAL("Failed to get an object with name " << Graphname); + m_resTGraph_CellBased2PanTau[ietaBin][imode] = std::unique_ptr<TGraph>(Graph); + ATH_MSG_DEBUG("Adding graph: "); + } + else { + ATH_MSG_FATAL("Failed to get an object with name " << Graphname); return StatusCode::FAILURE; } Graphname = "ConstituentEt/Graph_from_MeanEt_ConstituentEt_" + m_modeNames[imode] + "_" + m_etaBinNames[ietaBin]; Graph = dynamic_cast<TGraph*> (file->Get(Graphname.c_str())); if(Graph){ - m_meanTGraph_CellBased2PanTau[ietaBin].push_back(Graph); - ATH_MSG_DEBUG("Adding graph: "); - } else { + m_meanTGraph_CellBased2PanTau[ietaBin][imode] = std::unique_ptr<TGraph>(Graph); + ATH_MSG_DEBUG("Adding graph: "); + } + else { ATH_MSG_FATAL("Failed to get an object with name " << Graphname); return StatusCode::FAILURE; } - } - } + file->Close(); return StatusCode::SUCCESS; diff --git a/Reconstruction/tauRecTools/Root/HelperFunctions.cxx b/Reconstruction/tauRecTools/Root/HelperFunctions.cxx index 4ee6848854bab72c9bff654526cbfe949dffcf6c..68001ecac838431a6e4337110c439c14a90816c5 100644 --- a/Reconstruction/tauRecTools/Root/HelperFunctions.cxx +++ b/Reconstruction/tauRecTools/Root/HelperFunctions.cxx @@ -60,17 +60,17 @@ std::vector<TString> tauRecTools::parseStringMVAUtilsBDT(const TString& str, con } //________________________________________________________________________________ -MVAUtils::BDT* tauRecTools::configureMVABDT( std::map<TString, float*> &availableVars, const TString& weightFile){ - TFile* fBDT = TFile::Open( weightFile ); +std::unique_ptr<MVAUtils::BDT> tauRecTools::configureMVABDT( std::map<TString, float*> &availableVars, const TString& weightFile){ + std::unique_ptr<TFile> fBDT(TFile::Open(weightFile)); if(!fBDT){ std::cerr << "ERROR Cannot find tau input BDT file: " << weightFile << std::endl; - return 0; + return nullptr; } + TTree* tBDT = dynamic_cast<TTree*> (fBDT->Get("BDT")); if(!tBDT){ - delete fBDT; std::cerr << "ERROR Cannot find tau input BDT tree" << std::endl; - return 0; + return nullptr; } std::cout << "tauRecTools::configureMVABDT opened file: " << weightFile << std::endl; @@ -81,47 +81,44 @@ MVAUtils::BDT* tauRecTools::configureMVABDT( std::map<TString, float*> &availabl TNamed* n_varList = dynamic_cast<TNamed*> (fBDT->Get("varList")); if(!n_varList) { std::cerr << "ERROR no Variable List in file : " << weightFile << std::endl; - delete fBDT; - return 0; + return nullptr; } std::vector<TString> varList_ar = tauRecTools::parseStringMVAUtilsBDT(n_varList->GetTitle()); + delete n_varList; + for(const TString& str : varList_ar){ if(str.Length()==0) continue; std::map<TString, float*>::iterator itr = availableVars.find(str); if(itr==availableVars.end()){ std::cerr << "ERROR Variable : " << str << " is not available" << std::endl; - delete fBDT; - delete n_varList; - return 0; + return nullptr; } vars.push_back( itr->second ); } - MVAUtils::BDT* reader = new MVAUtils::BDT(tBDT); + auto reader = std::make_unique<MVAUtils::BDT>(tBDT); reader->SetPointers( vars ); - delete n_varList; - delete fBDT; + fBDT->Close(); return reader; - } //________________________________________________________________________________ tauRecTools::TRTBDT::TRTBDT(const char* weightFile){ - this->bdt = 0; + this->bdt = nullptr; init(weightFile); } //________________________________________________________________________________ bool tauRecTools::TRTBDT::init(const char* weightFile){ - TFile* fBDT = TFile::Open( weightFile ); + std::unique_ptr<TFile> fBDT(TFile::Open(weightFile)); if(!fBDT){ std::cerr << "ERROR Cannot find tau input BDT file: " << weightFile << std::endl; return 0; } + TTree* tBDT = dynamic_cast<TTree*> (fBDT->Get("BDT")); if(!tBDT){ - delete fBDT; std::cerr << "ERROR Cannot find tau input BDT tree" << std::endl; return 0; } @@ -133,11 +130,12 @@ bool tauRecTools::TRTBDT::init(const char* weightFile){ TNamed* n_varList = dynamic_cast<TNamed*> (fBDT->Get("varList")); if(!n_varList) { std::cerr << "ERROR no Variable List in file : " << weightFile << std::endl; - delete fBDT; return 0; } std::vector<TString> varList_ar = tauRecTools::parseStringMVAUtilsBDT(n_varList->GetTitle()); + delete n_varList; + for(TString str : varList_ar){ if(str.Length()==0) continue; @@ -152,11 +150,11 @@ bool tauRecTools::TRTBDT::init(const char* weightFile){ vars.push_back(fval); } - this->bdt = new MVAUtils::BDT(tBDT); + this->bdt = std::make_unique<MVAUtils::BDT>(tBDT); this->bdt->SetPointers( vars ); + + fBDT->Close(); - delete n_varList; - delete fBDT; return true; } diff --git a/Reconstruction/tauRecTools/Root/MvaTESEvaluator.cxx b/Reconstruction/tauRecTools/Root/MvaTESEvaluator.cxx index a6ea56445feffd0ba9047ea3fccbdcb4a9bcfdf3..9cab6f6f99afe6626d288da4d9604d5e02ae2051 100644 --- a/Reconstruction/tauRecTools/Root/MvaTESEvaluator.cxx +++ b/Reconstruction/tauRecTools/Root/MvaTESEvaluator.cxx @@ -6,15 +6,12 @@ #include "tauRecTools/MvaTESEvaluator.h" #include "tauRecTools/HelperFunctions.h" -#include "TFile.h" -#include "TTree.h" - #include <vector> //_____________________________________________________________________________ MvaTESEvaluator::MvaTESEvaluator(const std::string& name) : TauRecToolBase(name) - , m_reader(0) + , m_reader(nullptr) , m_mu(0) , m_nVtxPU(0) , m_center_lambda(0) @@ -98,7 +95,7 @@ StatusCode MvaTESEvaluator::initialize(){ std::string weightFile = find_file(m_sWeightFileName); m_reader = tauRecTools::configureMVABDT( m_availableVars, weightFile.c_str() ); - if(m_reader==0) { + if(m_reader==nullptr) { ATH_MSG_FATAL("Couldn't configure MVA"); return StatusCode::FAILURE; } diff --git a/Reconstruction/tauRecTools/Root/TauCalibrateLC.cxx b/Reconstruction/tauRecTools/Root/TauCalibrateLC.cxx index a359d1794e3d05a0ea6e77c843a60849e77744ce..f43b6c67262265bcb5da7921b18b2ef37aaa8e81 100644 --- a/Reconstruction/tauRecTools/Root/TauCalibrateLC.cxx +++ b/Reconstruction/tauRecTools/Root/TauCalibrateLC.cxx @@ -63,7 +63,7 @@ StatusCode TauCalibrateLC::initialize() { std::string fullPath = find_file(m_calibrationFile); - TFile * file = TFile::Open(fullPath.c_str(), "READ"); + std::unique_ptr<TFile> file(TFile::Open(fullPath.c_str(), "READ")); if (!file) { ATH_MSG_FATAL("Failed to open " << fullPath); @@ -72,12 +72,10 @@ StatusCode TauCalibrateLC::initialize() { // get the histogram defining eta binning std::string key = "etaBinning"; - TObject * obj = file->Get(key.c_str()); - TH1* histo = dynamic_cast<TH1*> (obj); - m_etaBinHist = NULL; + TH1* histo = dynamic_cast<TH1*>(file->Get(key.c_str())); if (histo) { histo->SetDirectory(0); - m_etaBinHist = histo; + m_etaBinHist = std::unique_ptr<TH1>(histo); } else { ATH_MSG_FATAL("Failed to get an object with key " << key); @@ -97,12 +95,10 @@ StatusCode TauCalibrateLC::initialize() { // get the histogram with eta corrections key = "etaCorrection"; - obj = file->Get(key.c_str()); - histo = dynamic_cast<TH1*> (obj); - m_etaCorrectionHist = NULL; + histo = dynamic_cast<TH1*>(file->Get(key.c_str())); if (histo) { histo->SetDirectory(0); - m_etaCorrectionHist = histo; + m_etaCorrectionHist = std::unique_ptr<TH1>(histo); } else { ATH_MSG_FATAL("Failed to get an object with key " << key); @@ -112,13 +108,21 @@ StatusCode TauCalibrateLC::initialize() { TString tmpSlopKey[s_nProngBins] = {"slopeNPV1P", "slopeNPV3P"}; TString tmpFuncBase[s_nProngBins] = {"OneP_Eta_", "MultiP_Eta_"}; + /// m_slopeNPVHist with size of s_nProngBins + m_slopeNPVHist.resize(s_nProngBins); + + /// m_calibFunc with size of (s_nProngBins, m_nEtaBins) + m_calibFunc.resize(s_nProngBins); + for (int i = 0; i < s_nProngBins; ++i) { + m_calibFunc[i].resize(m_nEtaBins); + } + + for (int i = 0; i < s_nProngBins; i++) { - obj = file->Get(tmpSlopKey[i]); // get pile-up slope histograms - histo = dynamic_cast<TH1*> (obj); - m_slopeNPVHist[i] = NULL; + histo = dynamic_cast<TH1*>(file->Get(tmpSlopKey[i])); // get pile-up slope histograms if (histo) { histo->SetDirectory(0); - m_slopeNPVHist[i] = histo; + m_slopeNPVHist[i] = std::unique_ptr<TH1>(histo); } else { ATH_MSG_FATAL("Failed to get an object with key " << tmpSlopKey[i]); @@ -128,15 +132,13 @@ StatusCode TauCalibrateLC::initialize() { for (int j = 0; j < m_nEtaBins; j++) { TString key = tmpFuncBase[i]; key += j; - TObject * obj = file->Get(key); - TF1* fcn = dynamic_cast<TF1*> (obj); - m_calibFunc[i][j] = NULL; + TF1* fcn = dynamic_cast<TF1*>(file->Get(key)); if (fcn) { - m_calibFunc[i][j] = fcn; + m_calibFunc[i][j] = std::unique_ptr<TF1>(fcn); } else { - ATH_MSG_FATAL("Failed to get an object with key " << key); - return StatusCode::FAILURE; + ATH_MSG_FATAL("Failed to get an object with key " << key); + return StatusCode::FAILURE; } } } diff --git a/Reconstruction/tauRecTools/Root/TauJetBDTEvaluator.cxx b/Reconstruction/tauRecTools/Root/TauJetBDTEvaluator.cxx index a5f8bc9c1d0e1732e112014d7ef151fc50a4fe5d..7dc66c4a343e05a3b6f403f468aea2e7c710c788 100644 --- a/Reconstruction/tauRecTools/Root/TauJetBDTEvaluator.cxx +++ b/Reconstruction/tauRecTools/Root/TauJetBDTEvaluator.cxx @@ -6,7 +6,7 @@ TauJetBDTEvaluator::TauJetBDTEvaluator(const std::string& name) : TauRecToolBase(name) - , m_myBdt(0) + , m_myBdt(nullptr) { declareProperty("weightsFile", m_weightsFile=""); declareProperty("minNTracks", m_minNTracks=0); @@ -29,8 +29,8 @@ StatusCode TauJetBDTEvaluator::initialize(){ //configure m_myBdt object if weights exists std::string full_path=find_file(m_weightsFile); - m_myBdt = new tauRecTools::TRTBDT(full_path.c_str()); - if(m_myBdt->bdt==0) { + m_myBdt = std::make_unique<tauRecTools::TRTBDT>(full_path.c_str()); + if(m_myBdt->bdt==nullptr) { ATH_MSG_FATAL("Couldn't configure BDT"); return StatusCode::FAILURE; } @@ -44,7 +44,7 @@ StatusCode TauJetBDTEvaluator::execute(xAOD::TauJet& xTau){ //init output variable accessor SG::AuxElement::Accessor<float> outputVar(m_outputVarName); - if(m_myBdt==0) { + if(m_myBdt==nullptr) { (outputVar)(xTau) = m_dummyValue; return StatusCode::SUCCESS; } diff --git a/Reconstruction/tauRecTools/Root/TauPi0ScoreCalculator.cxx b/Reconstruction/tauRecTools/Root/TauPi0ScoreCalculator.cxx index ef5da4bca49aa40b7c51a0749452ee2e33c2409b..ed9df0189f1f36087e7b71e4690106925755f1c0 100644 --- a/Reconstruction/tauRecTools/Root/TauPi0ScoreCalculator.cxx +++ b/Reconstruction/tauRecTools/Root/TauPi0ScoreCalculator.cxx @@ -27,7 +27,7 @@ using std::string; TauPi0ScoreCalculator::TauPi0ScoreCalculator( const string& name ) : TauRecToolBase(name), - m_mvaBDT(0), + m_mvaBDT(nullptr), m_Abs_FIRST_ETA(0), m_SECOND_R(0), m_SECOND_LAMBDA(0), @@ -86,7 +86,7 @@ StatusCode TauPi0ScoreCalculator::initialize() std::string weightFile = find_file(m_weightfile); m_mvaBDT = tauRecTools::configureMVABDT(m_availableVars, weightFile); - if(m_mvaBDT==0) { + if(m_mvaBDT==nullptr) { ATH_MSG_FATAL("Couldn't configure MVA"); return StatusCode::FAILURE; } diff --git a/Reconstruction/tauRecTools/Root/TauTrackClassifier.cxx b/Reconstruction/tauRecTools/Root/TauTrackClassifier.cxx index f46da0571d34b374ea0a03f85fe4dd582f69823c..cc04d313f44dea2eefaf2e54f1f803e33e7d8854 100644 --- a/Reconstruction/tauRecTools/Root/TauTrackClassifier.cxx +++ b/Reconstruction/tauRecTools/Root/TauTrackClassifier.cxx @@ -123,7 +123,7 @@ TrackMVABDT::TrackMVABDT(const std::string& sName) , m_iSignalType(xAOD::TauJetParameters::classifiedCharged) , m_iBackgroundType(xAOD::TauJetParameters::classifiedFake) , m_iExpectedFlag(xAOD::TauJetParameters::unclassified) - , m_rReader(0) + , m_rReader(nullptr) , m_mAvailableVars({}) { declareProperty( "InputWeightsPath", m_sInputWeightsPath ); @@ -136,14 +136,11 @@ TrackMVABDT::TrackMVABDT(const std::string& sName) //______________________________________________________________________________ TrackMVABDT::~TrackMVABDT() { - delete m_rReader; } //______________________________________________________________________________ StatusCode TrackMVABDT::finalize() { - delete m_rReader; - m_rReader = nullptr; for( std::pair<TString, float*> p : m_mAvailableVars ) delete p.second; m_mAvailableVars.clear(); return StatusCode::SUCCESS; @@ -247,7 +244,7 @@ StatusCode TrackMVABDT::addWeightsFile() ATH_MSG_DEBUG("InputWeightsPath: " << m_sInputWeightsPath); m_rReader = tauRecTools::configureMVABDT( m_mAvailableVars, m_sInputWeightsPath.c_str() ); - if(m_rReader==0) { + if(m_rReader==nullptr) { ATH_MSG_FATAL("Couldn't configure MVA"); return StatusCode::FAILURE; } diff --git a/Reconstruction/tauRecTools/Root/TauWPDecorator.cxx b/Reconstruction/tauRecTools/Root/TauWPDecorator.cxx index 829b82adf0a945ec460fee454de29ae58d20ca92..3a899cfeefd836ee3d074ab09ac1f232d7a2e29c 100644 --- a/Reconstruction/tauRecTools/Root/TauWPDecorator.cxx +++ b/Reconstruction/tauRecTools/Root/TauWPDecorator.cxx @@ -57,7 +57,7 @@ StatusCode TauWPDecorator::retrieveHistos(int nProng) { } std::string fullPath = find_file(fileName); - TFile * myFile = TFile::Open(fullPath.c_str(), "READ"); + std::unique_ptr<TFile> myFile(TFile::Open(fullPath.c_str(), "READ")); if(!myFile || myFile->IsZombie()) { ATH_MSG_FATAL("Could not open file " << fullPath.c_str()); @@ -68,20 +68,21 @@ StatusCode TauWPDecorator::retrieveHistos(int nProng) { // Iterate over working points for(int i=0; i<100; i++) - { - // Retrieve histogram - TH2* myGraph = (TH2*)myFile->Get(Form("h2_%02d", i)); - if(!myGraph){ - ATH_MSG_WARNING("Failed to retrieve Graph " << i << " named " << Form("h2_%02d", i)); - continue; - } - - // Clone histogram and store locally - std::unique_ptr<TH2> myLocalGraph((TH2*)myGraph->Clone()); - myLocalGraph->SetDirectory(0); - histArray->push_back(m_pair_t(float(i)/100., std::move(myLocalGraph))); + { + // Retrieve histogram + TH2* myGraph = dynamic_cast<TH2*>(myFile->Get(Form("h2_%02d", i))); + if(!myGraph){ + ATH_MSG_WARNING("Failed to retrieve Graph " << i << " named " << Form("h2_%02d", i)); + continue; } + + std::unique_ptr<TH2> myLocalGraph(myGraph); + myLocalGraph->SetDirectory(0); + histArray->push_back(m_pair_t(float(i)/100., std::move(myLocalGraph))); + } + myFile->Close(); + return StatusCode::SUCCESS; } diff --git a/Reconstruction/tauRecTools/tauRecTools/CombinedP4FromRecoTaus.h b/Reconstruction/tauRecTools/tauRecTools/CombinedP4FromRecoTaus.h index 13bb9e2d9a3147a4f8ff8d7ecc46abba29f7dd41..dfc495069b9ffb77adfb52dd6eeeabb23f0a833e 100644 --- a/Reconstruction/tauRecTools/tauRecTools/CombinedP4FromRecoTaus.h +++ b/Reconstruction/tauRecTools/tauRecTools/CombinedP4FromRecoTaus.h @@ -70,15 +70,18 @@ class CombinedP4FromRecoTaus StatusCode execute(xAOD::TauJet& xTau) override; private: - std::vector< std::vector<TGraph*> > m_resTGraph_tauRec; - std::vector< std::vector<TGraph*> > m_resTGraph_CellBased2PanTau; - std::vector< std::vector<TGraph*> > m_meanTGraph_CellBased2PanTau; - std::vector< std::vector<TGraph*> > m_meanTGraph_tauRec; - - std::vector<TH1F*> m_correlationHists; - - std::vector<TString> m_modeNames = {"1p0n","1p1n","1pXn","3p0n","3pXn"}; - std::vector<TString> m_etaBinNames = {"0", "1", "2", "3", "4"};//("<0.3"), ("<0.8"), ("<1.3"), ("<1.6"), ("<2.5") + const std::vector<TString> m_modeNames = {"1p0n","1p1n","1pXn","3p0n","3pXn"}; + const std::vector<TString> m_etaBinNames = {"0", "1", "2", "3", "4"};//("<0.3"), ("<0.8"), ("<1.3"), ("<1.6"), ("<2.5") + + /// row: size of m_etaBinNames, column: size of m_modeNames + std::vector<std::vector<std::unique_ptr<TGraph>>> m_meanTGraph_CellBased2PanTau; + std::vector<std::vector<std::unique_ptr<TGraph>>> m_resTGraph_CellBased2PanTau; + + std::vector<std::vector<std::unique_ptr<TGraph>>> m_meanTGraph_tauRec; + std::vector<std::vector<std::unique_ptr<TGraph>>> m_resTGraph_tauRec; + + /// size of m_modeNames + std::vector<std::unique_ptr<TH1F>> m_correlationHists; std::string m_calibFilePath; diff --git a/Reconstruction/tauRecTools/tauRecTools/HelperFunctions.h b/Reconstruction/tauRecTools/tauRecTools/HelperFunctions.h index 9678168b0e8f78c0b725c945b16be4efa2bd5ae7..bd299e71664ef26bec47a4b0a4a345f731ac9609 100644 --- a/Reconstruction/tauRecTools/tauRecTools/HelperFunctions.h +++ b/Reconstruction/tauRecTools/tauRecTools/HelperFunctions.h @@ -50,7 +50,7 @@ namespace tauRecTools float GetGradBoostMVA();//GradBost float GetClassification();//AdaBoost float GetResponse();//regression - MVAUtils::BDT* bdt=0; + std::unique_ptr<MVAUtils::BDT> bdt; std::map< float*, DummyAccessor* > m_data; TRTBDT( const char* weightFile); bool init(const char* weightFile); @@ -58,7 +58,7 @@ namespace tauRecTools bool updateVariables(const xAOD::TauJet& tau); }; - MVAUtils::BDT* configureMVABDT( std::map<TString, float*> &availableVars, const TString& weightFile); + std::unique_ptr<MVAUtils::BDT> configureMVABDT( std::map<TString, float*> &availableVars, const TString& weightFile); std::vector<TString> parseString(const TString& str, const TString& delim=","); std::vector<TString> parseStringMVAUtilsBDT(const TString& str, const TString& delim=","); diff --git a/Reconstruction/tauRecTools/tauRecTools/MvaTESEvaluator.h b/Reconstruction/tauRecTools/tauRecTools/MvaTESEvaluator.h index 94b1ec2e36cb788089454021745702f17cf83660..6a2d588e5222ec7b519e3720bdc0a3d726f2e639 100644 --- a/Reconstruction/tauRecTools/tauRecTools/MvaTESEvaluator.h +++ b/Reconstruction/tauRecTools/tauRecTools/MvaTESEvaluator.h @@ -29,7 +29,7 @@ class MvaTESEvaluator // Configurable properties std::string m_sWeightFileName; - MVAUtils::BDT *m_reader; //! + std::unique_ptr<MVAUtils::BDT> m_reader; //! std::map<TString, float*> m_availableVars; //!< addresses of the floats below diff --git a/Reconstruction/tauRecTools/tauRecTools/TauCalibrateLC.h b/Reconstruction/tauRecTools/tauRecTools/TauCalibrateLC.h index 7aa0d9105ef5c5eb88ab2693feb1d689eefe7454..5c32cb32bab080861a0203b1ef507ae92150c40a 100644 --- a/Reconstruction/tauRecTools/tauRecTools/TauCalibrateLC.h +++ b/Reconstruction/tauRecTools/tauRecTools/TauCalibrateLC.h @@ -40,10 +40,10 @@ private: static const int s_nProngBins = 2; - const TF1 * m_calibFunc[s_nProngBins][10]; //maximum 10 eta bins; might not be used on the whole - const TH1 * m_slopeNPVHist[s_nProngBins]={0}; - const TH1 * m_etaBinHist=0; - const TH1 * m_etaCorrectionHist=0; + std::vector<std::vector<std::unique_ptr<TF1>>> m_calibFunc; + std::vector<std::unique_ptr<TH1>> m_slopeNPVHist; + std::unique_ptr<TH1> m_etaBinHist=nullptr; + std::unique_ptr<TH1> m_etaCorrectionHist=nullptr; ToolHandle<ILumiBlockMuTool> m_lumiBlockMuTool; diff --git a/Reconstruction/tauRecTools/tauRecTools/TauJetBDTEvaluator.h b/Reconstruction/tauRecTools/tauRecTools/TauJetBDTEvaluator.h index d6ca8cd9aa635679307037154e44214f6cd490a4..2c1fdb84e4f5c8c96f45ba0c2ebf931c8956fc56 100644 --- a/Reconstruction/tauRecTools/tauRecTools/TauJetBDTEvaluator.h +++ b/Reconstruction/tauRecTools/tauRecTools/TauJetBDTEvaluator.h @@ -36,7 +36,7 @@ class TauJetBDTEvaluator std::string m_weightsFile; std::string m_outputVarName; - tauRecTools::TRTBDT* m_myBdt=0; + std::unique_ptr<tauRecTools::TRTBDT> m_myBdt; int m_minNTracks; int m_maxNTracks; float m_minAbsTrackEta; diff --git a/Reconstruction/tauRecTools/tauRecTools/TauPi0ScoreCalculator.h b/Reconstruction/tauRecTools/tauRecTools/TauPi0ScoreCalculator.h index 2f0d42abdbafedf9a4fd9881fc273fb60c4a77d1..5d63b329d4a92a63e293bbe4278d60f6cd23029a 100644 --- a/Reconstruction/tauRecTools/tauRecTools/TauPi0ScoreCalculator.h +++ b/Reconstruction/tauRecTools/tauRecTools/TauPi0ScoreCalculator.h @@ -32,7 +32,7 @@ public: virtual StatusCode executePi0nPFO(xAOD::TauJet& pTau, xAOD::PFOContainer& pNeutralPFOContainer) override; private: - MVAUtils::BDT* m_mvaBDT; + std::unique_ptr<MVAUtils::BDT> m_mvaBDT; std::string m_weightfile; @@ -64,10 +64,6 @@ private: /** @brief function used to calculate BDT score */ float calculateScore(const xAOD::PFO* neutralPFO); - - /* /\** @brief Book TMVA methods. *\/ */ - /* StatusCode bookMethod(TMVA::Reader *reader, const std::string &methodName) const; */ - }; #endif /* TAUPI0SCORECALCULATOR_H */ diff --git a/Reconstruction/tauRecTools/tauRecTools/TauTrackClassifier.h b/Reconstruction/tauRecTools/tauRecTools/TauTrackClassifier.h index 76dc6237a214ccf38f51befd3c96f8d5d5e5ad91..89124def597809035224ff641a8ead38414bb2df 100644 --- a/Reconstruction/tauRecTools/tauRecTools/TauTrackClassifier.h +++ b/Reconstruction/tauRecTools/tauRecTools/TauTrackClassifier.h @@ -89,8 +89,7 @@ private: int m_iBackgroundType; int m_iExpectedFlag; -private: - MVAUtils::BDT* m_rReader; //! + std::unique_ptr<MVAUtils::BDT> m_rReader; //! // std::map<int, std::string> m_mParsedVarsBDT; //! std::map<TString, float*> m_mAvailableVars; //!