diff --git a/Event/xAOD/xAODBPhys/Root/BPhysHelper.cxx b/Event/xAOD/xAODBPhys/Root/BPhysHelper.cxx index 68ea9f2a5bfbdd6b2bf3a7503d0fccb52a6ab7a4..819060d7ed7e928bfb4a40fa2a239e0fe81e5f40 100644 --- a/Event/xAOD/xAODBPhys/Root/BPhysHelper.cxx +++ b/Event/xAOD/xAODBPhys/Root/BPhysHelper.cxx @@ -283,9 +283,9 @@ float xAOD::BPhysHelper::refTrkCharge(const size_t index) const } /*****************************************************************************/ -bool xAOD::BPhysHelper::setRefTrks(const std::vector<float>& px, - const std::vector<float>& py, - const std::vector<float>& pz) +bool xAOD::BPhysHelper::setRefTrks(std::vector<float> px, + std::vector<float> py, + std::vector<float> pz) { // sanity check: if(px.size()!=py.size() || px.size()!=pz.size()) @@ -301,9 +301,9 @@ bool xAOD::BPhysHelper::setRefTrks(const std::vector<float>& px, static const SG::AuxElement::Decorator< std::vector<float> > refTrackPzDeco("RefTrackPz"); // store the elements: - refTrackPxDeco(*m_b) = px; - refTrackPyDeco(*m_b) = py; - refTrackPzDeco(*m_b) = pz; + refTrackPxDeco(*m_b) = std::move(px); + refTrackPyDeco(*m_b) = std::move(py); + refTrackPzDeco(*m_b) = std::move(pz); return true; } @@ -319,7 +319,9 @@ bool xAOD::BPhysHelper::setRefTrks(const std::vector<TVector3>& refTrks) std::vector<float> px; std::vector<float> py; std::vector<float> pz; - + px.reserve(refTrks.size()); + py.reserve(refTrks.size()); + pz.reserve(refTrks.size()); // loop over refitted track momenta and store the components std::vector<TVector3>::const_iterator refTrksItr = refTrks.begin(); for(; refTrksItr!=refTrks.end(); ++refTrksItr) { @@ -329,7 +331,7 @@ bool xAOD::BPhysHelper::setRefTrks(const std::vector<TVector3>& refTrks) } // call overloaded method: - return setRefTrks(px,py,pz); + return setRefTrks(std::move(px),std::move(py),std::move(pz)); } @@ -342,9 +344,12 @@ bool xAOD::BPhysHelper::setRefTrks() std::vector<float> px; std::vector<float> py; std::vector<float> pz; - + const auto N = vtx()->vxTrackAtVertex().size(); + px.reserve(N); + py.reserve(N); + pz.reserve(N); // loop over refitted tracks at vertex - for(uint i=0; i<vtx()->vxTrackAtVertex().size(); ++i) { + for(uint i=0; i<N; ++i) { const Trk::TrackParameters* aPerigee = vtx()->vxTrackAtVertex()[i].perigeeAtVertex(); //sanity check if(!aPerigee) @@ -357,7 +362,7 @@ bool xAOD::BPhysHelper::setRefTrks() } // store as augmentation: - setRefTrks(px, py, pz); + setRefTrks(std::move(px), std::move(py), std::move(pz)); // all OK return true; @@ -506,7 +511,7 @@ bool xAOD::BPhysHelper::setMuons(const std::vector<const xAOD::Muon*>& muons, } // end of loop over muons // all OK: store muon links in the aux store - muonLinksDecor(*m_b) = muonLinks; + muonLinksDecor(*m_b) = std::move(muonLinks); return true; @@ -586,7 +591,7 @@ bool xAOD::BPhysHelper::setElectrons(const std::vector<const xAOD::Electron*>& e } // end of loop over electrons // all OK: store electron links in the aux store - electronLinksDecor(*m_b) = electronLinks; + electronLinksDecor(*m_b) = std::move(electronLinks); return true; @@ -668,7 +673,7 @@ bool xAOD::BPhysHelper::setPrecedingVertices(const std::vector<const xAOD::Verte } // end of loop over preceding vertices // all OK: store preceding vertex links in the aux store - precedingVertexLinksDecor(*m_b) = precedingVertexLinks; + precedingVertexLinksDecor(*m_b) = std::move(precedingVertexLinks); return true; @@ -749,7 +754,7 @@ bool xAOD::BPhysHelper::setCascadeVertices(const std::vector<const xAOD::Vertex* } // end of loop over cascade vertices // all OK: store cascade vertex links in the aux store - cascadeVertexLinksDecor(*m_b) = cascadeVertexLinks; + cascadeVertexLinksDecor(*m_b) = std::move(cascadeVertexLinks); return true; diff --git a/Event/xAOD/xAODBPhys/Root/BPhysHypoHelper.cxx b/Event/xAOD/xAODBPhys/Root/BPhysHypoHelper.cxx index 932a9739f2eda72513d83e8bc5e6a17392273fda..717fefd6e28457334a66db8c268e3eb5c6248109 100644 --- a/Event/xAOD/xAODBPhys/Root/BPhysHypoHelper.cxx +++ b/Event/xAOD/xAODBPhys/Root/BPhysHypoHelper.cxx @@ -36,12 +36,12 @@ /** @} */ /*****************************************************************************/ -float xAOD::BPhysHypoHelper::mass() +float xAOD::BPhysHypoHelper::mass() const { GET_FLOAT( m_hypo+"_mass" ); } /*****************************************************************************/ -float xAOD::BPhysHypoHelper::massErr() +float xAOD::BPhysHypoHelper::massErr() const { GET_FLOAT( m_hypo+"_massErr" ); } diff --git a/Event/xAOD/xAODBPhys/xAODBPhys/BPhysHelper.h b/Event/xAOD/xAODBPhys/xAODBPhys/BPhysHelper.h index a301c6a5818ba0c1b686cc2e7d08009dcf60e652..d568e3e552b28ef595e6e58d93da8e5736b11621 100644 --- a/Event/xAOD/xAODBPhys/xAODBPhys/BPhysHelper.h +++ b/Event/xAOD/xAODBPhys/xAODBPhys/BPhysHelper.h @@ -68,9 +68,9 @@ /** Base class for the B-physcis xAOD helpers */ namespace xAOD { - class BPhysHelper { + public: /************************************************************************/ @@ -232,9 +232,9 @@ namespace xAOD { * @returns: true on success */ - bool setRefTrks(const std::vector<float>& px, - const std::vector<float>& py, - const std::vector<float>& pz); + bool setRefTrks(std::vector<float> px, + std::vector<float> py, + std::vector<float> pz); /** Sets refitted track momenta * @param[in] refTrks std::vector of refitted momenta as TVector3 diff --git a/Event/xAOD/xAODBPhys/xAODBPhys/BPhysHypoHelper.h b/Event/xAOD/xAODBPhys/xAODBPhys/BPhysHypoHelper.h index 87a8dc1d9537296b0a57a6f4d3c15f5f16f29269..b6d120ce640159e95163cfc2f9bfed0f7ac9ad0b 100644 --- a/Event/xAOD/xAODBPhys/xAODBPhys/BPhysHypoHelper.h +++ b/Event/xAOD/xAODBPhys/xAODBPhys/BPhysHypoHelper.h @@ -64,10 +64,6 @@ #include "BPhysHelper.h" -#include "TVector3.h" -#include "TLorentzVector.h" -#include "TMatrixTSym.h" - #include <assert.h> @@ -87,7 +83,7 @@ namespace xAOD { * @param[in] hypo Name of the hypothesis * @param[in] b Pointer to the xAOD::Vertex */ - BPhysHypoHelper(const std::string hypo, const xAOD::Vertex* b) : + BPhysHypoHelper(const std::string &hypo, const xAOD::Vertex* b) : BPhysHelper(b), m_hypo(hypo) { @@ -104,8 +100,8 @@ namespace xAOD { * @returns: mass or error, -9999999. in case the augmentation doesn't exist */ - float mass(); //!< invariant mass - float massErr(); //!< invariant mass error + float mass() const; //!< invariant mass + float massErr() const; //!< invariant mass error /** Set given invariant mass and its error *