diff --git a/Event/xAOD/xAODMissingET/Root/MissingETAssociation_v1.cxx b/Event/xAOD/xAODMissingET/Root/MissingETAssociation_v1.cxx index 46683d9bd7cf6677d690d7684f05a99c103105f4..6793e2441ee49922c6b3cba365d03afb2d516dad 100644 --- a/Event/xAOD/xAODMissingET/Root/MissingETAssociation_v1.cxx +++ b/Event/xAOD/xAODMissingET/Root/MissingETAssociation_v1.cxx @@ -68,13 +68,6 @@ namespace xAOD { return sqrt(this->cpx()*this->cpx()+this->cpy()*this->cpy()); } - /////////////////////////////// - // Internally used constants // - /////////////////////////////// - - size_t MissingETAssociation_v1::m_objConstLinkReserve = 50; - size_t MissingETAssociation_v1::m_contribObjReserve = 10; - ////////////////////////////////// // Constructors and destructors // ////////////////////////////////// diff --git a/Event/xAOD/xAODMissingET/Root/MissingETComponentMap_v1.cxx b/Event/xAOD/xAODMissingET/Root/MissingETComponentMap_v1.cxx index 0d2a8d1cdb44717d492821bf00905022d3725049..d919d475f4998687d13a9038db992332c2205b6e 100644 --- a/Event/xAOD/xAODMissingET/Root/MissingETComponentMap_v1.cxx +++ b/Event/xAOD/xAODMissingET/Root/MissingETComponentMap_v1.cxx @@ -24,9 +24,6 @@ using namespace xAOD; size_t MissingETComponentMap_v1::m_clusterLinkReserve = 10000; size_t MissingETComponentMap_v1::m_trackLinkReserve = 10000; -size_t MissingETComponentMap_v1::m_maxClusterSize = 5000; -size_t MissingETComponentMap_v1::m_maxTrackSize = 5000; -size_t MissingETComponentMap_v1::m_maxSignalSize = fmax(m_maxTrackSize,m_maxClusterSize); ///////////////////////////////// // Constructors and destructor // @@ -34,8 +31,6 @@ size_t MissingETComponentMap_v1::m_maxSignalSize = fmax(m_maxTrackSize,m_ma MissingETComponentMap_v1::MissingETComponentMap_v1(SG::OwnershipPolicy own, SG::IndexTrackingPolicy trackIndices) : DataVector<MissingETComponent_v1>(own,trackIndices) - , m_lastMETObject((const MissingET*)0) - , m_lastContribIndex(MissingETBase::Numerical::invalidIndex()) { this->f_setupLookupCache(m_clusterLinks,m_clusterLinkReserve); this->f_setupLookupCache(m_trackLinks,m_trackLinkReserve); @@ -44,8 +39,6 @@ MissingETComponentMap_v1::MissingETComponentMap_v1(SG::OwnershipPolicy own, SG:: MissingETComponentMap_v1::MissingETComponentMap_v1(MissingETComponentMap_v1::iterator first, MissingETComponentMap_v1::iterator last, SG::OwnershipPolicy own, SG::IndexTrackingPolicy trackIndices) : DataVector<MissingETComponent_v1>(first,last,own,trackIndices) - , m_lastMETObject((const MissingET*)0) - , m_lastContribIndex(MissingETBase::Numerical::invalidIndex()) { this->f_setupLookupCache(m_clusterLinks,m_clusterLinkReserve); this->f_setupLookupCache(m_trackLinks,m_trackLinkReserve); @@ -59,127 +52,78 @@ MissingETComponentMap_v1::~MissingETComponentMap_v1() ///////////// MissingETComponentMap_v1::const_iterator MissingETComponentMap_v1::find(const MissingET* pMET) const -{ - if ( pMET == m_lastMETObject ) - { const_iterator fCont(this->begin()); std::advance<const_iterator>(fCont,m_lastContribIndex); return fCont; } - else { return this->f_findConst(pMET); } -} - -MissingETComponentMap_v1::iterator MissingETComponentMap_v1::find(const MissingET* pMET) -{ - if ( pMET == m_lastMETObject ) { iterator fCont(this->begin()); std::advance<iterator>(fCont,m_lastContribIndex); return fCont; } - else { return this->f_find(pMET); } -} - -MissingETComponentMap_v1::const_iterator MissingETComponentMap_v1::find(const std::string& name) const -{ - if ( m_lastMETObject == 0 || m_lastMETObject->name() != name ) { return this->f_findConst(name); } - else { const_iterator fCont(this->begin()); std::advance<const_iterator>(fCont,m_lastContribIndex); return fCont; } -} - -MissingETComponentMap_v1::iterator MissingETComponentMap_v1::find(const std::string& name) -{ - if ( m_lastMETObject == 0 || m_lastMETObject->name() != name ) { return this->f_find(name); } - else { iterator fCont(this->begin()); std::advance<iterator>(fCont,m_lastContribIndex); return fCont; } -} - -MissingETComponentMap_v1::const_iterator MissingETComponentMap_v1::find(MissingETBase::Types::bitmask_t src) const -{ - if ( m_lastMETObject == 0 || m_lastMETObject->source() != src ) { return this->f_findConst(src); } - else { const_iterator fCont(this->begin()); std::advance<const_iterator>(fCont,m_lastContribIndex); return fCont; } -} - -MissingETComponentMap_v1::iterator MissingETComponentMap_v1::find(MissingETBase::Types::bitmask_t src) -{ - if ( m_lastMETObject == 0 || m_lastMETObject->source() != src ) { return this->f_find(src); } - else { iterator fCont(this->begin()); std::advance<iterator>(fCont,m_lastContribIndex); return fCont; } -} - -size_t MissingETComponentMap_v1::findIndex(const MissingET* pMET) const -{ if ( m_lastMETObject != pMET ) { this->f_findConst(pMET); } return m_lastContribIndex; } - -size_t MissingETComponentMap_v1::findIndex(const std::string& name) const -{ if ( m_lastMETObject == 0 || this->at(m_lastContribIndex)->metObject()->name() != name ) { this->f_findConst(name); } return m_lastContribIndex; } - -size_t MissingETComponentMap_v1::findIndex(MissingETBase::Types::bitmask_t sw) const -{ if ( m_lastMETObject == 0 || this->at(m_lastContribIndex)->statusWord() != sw ) { this->f_findConst(sw); } return m_lastContribIndex; } - -/////////////////////// -// Protected finders // -/////////////////////// - -MissingETComponentMap_v1::const_iterator MissingETComponentMap_v1::f_findConst(const MissingET* pMET) const { const_iterator fCont(this->begin()); const_iterator lCont(this->end()); while ( fCont != lCont && (*fCont)->metObject() != pMET ) { ++fCont; } - this->f_setConstCache(fCont); return fCont; } -MissingETComponentMap_v1::iterator MissingETComponentMap_v1::f_find(const MissingET* pMET) +MissingETComponentMap_v1::iterator MissingETComponentMap_v1::find(const MissingET* pMET) { iterator fCont(this->begin()); iterator lCont(this->end()); while ( fCont != lCont && (*fCont)->metObject() != pMET ) { ++fCont; } - this->f_setCache(fCont); return fCont; } -MissingETComponentMap_v1::const_iterator MissingETComponentMap_v1::f_findConst(const std::string& name) const +MissingETComponentMap_v1::const_iterator MissingETComponentMap_v1::find(const std::string& name) const { const_iterator fCont(this->begin()); const_iterator lCont(this->end()); while (fCont != lCont && (*fCont)->metObject()->name() != name ) { ++fCont; } - this->f_setConstCache(fCont); return fCont; } -MissingETComponentMap_v1::iterator MissingETComponentMap_v1::f_find(const std::string& name) +MissingETComponentMap_v1::iterator MissingETComponentMap_v1::find(const std::string& name) { iterator fCont(this->begin()); iterator lCont(this->end()); while ( fCont != lCont && (*fCont)->metObject()->name() != name ) { ++fCont; } - this->f_setCache(fCont); return fCont; } -MissingETComponentMap_v1::const_iterator MissingETComponentMap_v1::f_findConst(MissingETBase::Types::bitmask_t src) const +MissingETComponentMap_v1::const_iterator MissingETComponentMap_v1::find(MissingETBase::Types::bitmask_t src) const { const_iterator fCont(this->begin()); const_iterator lCont(this->end()); while ( fCont != lCont && (*fCont)->metObject()->source() != src ) { ++fCont; } - this->f_setConstCache(fCont); return fCont; } -MissingETComponentMap_v1::iterator MissingETComponentMap_v1::f_find(MissingETBase::Types::bitmask_t src) +MissingETComponentMap_v1::iterator MissingETComponentMap_v1::find(MissingETBase::Types::bitmask_t src) { iterator fCont(this->begin()); iterator lCont(this->end()); while ( fCont != lCont && (*fCont)->metObject()->source() != src ) { ++fCont; } - this->f_setCache(fCont); return fCont; } -void MissingETComponentMap_v1::f_setConstCache(const_iterator fCont) const +size_t MissingETComponentMap_v1::findIndex(const MissingET* pMET) const { - if ( fCont != this->end() ) - { - m_lastMETObject = (*fCont)->metObject(); - m_lastContribIndex = (size_t)std::distance<const_iterator>(this->begin(),fCont); - } - else { m_lastMETObject = (const MissingET*)0; m_lastContribIndex = MissingETBase::Numerical::invalidIndex(); } + const_iterator fCont(this->begin()); + const_iterator lCont(this->end()); + while ( fCont != lCont && (*fCont)->metObject() != pMET ) { ++fCont; } + if ( fCont != lCont ) return (size_t)std::distance<const_iterator>(this->begin(),fCont); + return MissingETBase::Numerical::invalidIndex(); } -void MissingETComponentMap_v1::f_setCache(iterator fCont) +size_t MissingETComponentMap_v1::findIndex(const std::string& name) const { - if ( fCont != this->end() ) - { - m_lastMETObject = const_cast<const MissingET*>((*fCont)->metObject()); - m_lastContribIndex = std::distance<iterator>(this->begin(),fCont); - } - else { m_lastMETObject = (const MissingET*)0; m_lastContribIndex = MissingETBase::Numerical::invalidIndex(); } + const_iterator fCont(this->begin()); + const_iterator lCont(this->end()); + while ( fCont != lCont && (*fCont)->metObject()->name() != name ) { ++fCont; } + if ( fCont != lCont ) return (size_t)std::distance<const_iterator>(this->begin(),fCont); + return MissingETBase::Numerical::invalidIndex(); +} + +size_t MissingETComponentMap_v1::findIndex(MissingETBase::Types::bitmask_t src) const +{ + const_iterator fCont(this->begin()); + const_iterator lCont(this->end()); + while ( fCont != lCont && (*fCont)->metObject()->source() != src ) { ++fCont; } + if ( fCont != lCont ) return (size_t)std::distance<const_iterator>(this->begin(),fCont); + return MissingETBase::Numerical::invalidIndex(); } ///////////////////////// @@ -187,7 +131,13 @@ void MissingETComponentMap_v1::f_setCache(iterator fCont) ///////////////////////// const MissingET* MissingETComponentMap_v1::retrieveMissingET(const std::string& name) const -{ if ( m_lastMETObject == 0 || m_lastMETObject->name() != name ) { this->f_findConst(name); } return m_lastMETObject; } +{ + const_iterator fCont(this->begin()); + const_iterator lCont(this->end()); + while ( fCont != lCont && (*fCont)->metObject()->name() != name ) { ++fCont; } + if ( fCont != lCont ) return (*fCont)->metObject(); + return 0; +} const MissingET* MissingETComponentMap_v1::retrieveMissingET(MissingETBase::Types::bitmask_t src,bool excl) const { return excl ? this->f_retrieveMissingETExcl(src) : this->f_retrieveMissingETIncl(src); } @@ -200,42 +150,40 @@ const MissingET* MissingETComponentMap_v1::retrieveMissingET(MissingETBase::Type /////////////////////////////////// const MissingET* MissingETComponentMap_v1::f_retrieveMissingETExcl(MissingETBase::Types::bitmask_t src) const -{ if ( m_lastMETObject == 0 || m_lastMETObject->source() != src ) { this->f_findConst(src); } return m_lastMETObject; } +{ + const_iterator fCont(this->begin()); + const_iterator lCont(this->end()); + while ( fCont != lCont && (*fCont)->metObject()->source() != src ) { ++fCont; } + if ( fCont != lCont ) return (*fCont)->metObject(); + return 0; +} const MissingET* MissingETComponentMap_v1::f_retrieveMissingETExcl(MissingETBase::Types::bitmask_t src,MissingETBase::Types::bitmask_t sw) const { - if ( m_lastMETObject == 0 || ( m_lastMETObject->source() != src || this->at(m_lastContribIndex)->statusWord() != sw ) ) - { - const_iterator fCont(this->begin()); const_iterator lCont(this->end()); - while ( fCont != lCont && ( (*fCont)->metObject()->source() != src || (*fCont)->statusWord() != sw ) ) { ++fCont; } - this->f_setConstCache(fCont); - } - return m_lastMETObject; + const_iterator fCont(this->begin()); + const_iterator lCont(this->end()); + while ( fCont != lCont && ( (*fCont)->metObject()->source() != src || (*fCont)->statusWord() != sw ) ) { ++fCont; } + if ( fCont != lCont ) return (*fCont)->metObject(); + return 0; } const MissingET* MissingETComponentMap_v1::f_retrieveMissingETIncl(MissingETBase::Types::bitmask_t src) const { - if ( m_lastMETObject == 0 || !MissingETBase::Source::hasPattern(m_lastMETObject->source(),src) ) - { - const_iterator fCont(this->begin()); const_iterator lCont(this->end()); - while ( fCont != lCont && !MissingETBase::Source::hasPattern((*fCont)->metObject()->source(),src) ) { ++fCont; } - this->f_setConstCache(fCont); - } - return m_lastMETObject; + const_iterator fCont(this->begin()); + const_iterator lCont(this->end()); + while ( fCont != lCont && !MissingETBase::Source::hasPattern((*fCont)->metObject()->source(),src) ) { ++fCont; } + if ( fCont != lCont ) return (*fCont)->metObject(); + return 0; } const MissingET* MissingETComponentMap_v1::f_retrieveMissingETIncl(MissingETBase::Types::bitmask_t src,MissingETBase::Types::bitmask_t sw) const { - if ( m_lastMETObject == 0 || (!MissingETBase::Source::hasPattern(m_lastMETObject->source(),src) || - !MissingETBase::Status::Tags::hasPattern(this->at(m_lastContribIndex)->statusWord(),sw) ) ) - { - const_iterator fCont(this->begin()); const_iterator lCont(this->end()); - while ( fCont!= lCont && ( !MissingETBase::Source::hasPattern((*fCont)->metObject()->source(),src) || - !MissingETBase::Status::Tags::hasPattern((*fCont)->statusWord(),sw) ) ) - { ++fCont; } - this->f_setConstCache(fCont); - } - return m_lastMETObject; + const_iterator fCont(this->begin()); + const_iterator lCont(this->end()); + while ( fCont != lCont && ( !MissingETBase::Source::hasPattern((*fCont)->metObject()->source(),src) || + !MissingETBase::Status::Tags::hasPattern((*fCont)->statusWord(),sw) ) ) { ++fCont; } + if ( fCont != lCont ) return (*fCont)->metObject(); + return 0; } ///////////////////////////// @@ -274,22 +222,9 @@ bool MissingETComponentMap_v1::checkUsage(MissingETBase::Types::object_vector_t& return retVal; } -bool MissingETComponentMap_v1::f_checkObjectUsage(MissingETBase::Types::object_vector_t& signals,signal_vector_t& signalLinks) const +bool MissingETComponentMap_v1::f_checkObjectUsage(MissingETBase::Types::object_vector_t& signals, const signal_vector_t& signalLinks) const { - if ( signals.empty() ) { return false; } - // check if new event - if ( signalLinks.empty() ) // this also an indication that there is no overlap! - { - size_t nSig(m_maxSignalSize); - const IParticleContainer* pCont = static_cast<const IParticleContainer*>(signals.front()->container()); - // if ( pCont == 0 ) - // { printf("MissingETComponentMap::f_checkObjectUsage(...) - WARNING - cannot cast container pointer %p to IParticleContainer\n",(void*)signals.front()->container()); } - // else - nSig = pCont->size(); - indexedlink_t sw(MissingETBase::Numerical::invalidLink().get<0>(),MissingETBase::Numerical::invalidLink().get<1>()); - signalLinks.resize(nSig,sw); - return false; - } + if ( signals.empty() || signalLinks.empty() ) return false; // loop on signals size_t oldSize(signals.size()); MissingETBase::Types::object_vector_t::iterator fSig(signals.begin()); @@ -310,7 +245,7 @@ bool MissingETComponentMap_v1::f_checkObjectUsage(MissingETBase::Types::object_v return oldSize != signals.size(); } -bool MissingETComponentMap_v1::f_checkObjectUsage(MissingETBase::Types::object_vector_t& objects,particle_map_t& physicsLinks) const +bool MissingETComponentMap_v1::f_checkObjectUsage(MissingETBase::Types::object_vector_t& objects, const particle_map_t& physicsLinks) const { if ( objects.empty() ) { return false; } // @@ -361,13 +296,11 @@ bool MissingETComponentMap_v1::setClusters(const MissingET* pMET,const IParticle if(firstCluster) { firstCluster = false; if ( m_clusterLinks.empty() ) { - size_t nClus(m_maxClusterSize); const IParticleContainer* pCont(static_cast<const IParticleContainer*>((*fSig)->container())); // if ( pCont == 0 ) // { printf("MissingETComponentMap::setClusters(...) - WARNING - cannot access cluster container (invalid NULL pointer), use %i words\n",(int)nClus); } // else - nClus = pCont->size(); - m_clusterLinks.resize(nClus,MissingETBase::Numerical::invalidLink()); + m_clusterLinks.resize(pCont->size(), MissingETBase::Numerical::invalidLink()); } // empty cluster link list } //first cluster // all clusters refer to the same MET contribution @@ -388,7 +321,6 @@ bool MissingETComponentMap_v1::setTracks(const MissingET* pMET,const IParticle* indexedlink_t ld(cIdx,pIdx); // make sure cache is not cleared bool firstTrack = true; - size_t nTrack(m_maxTrackSize); MissingETBase::Types::object_vector_t::const_iterator fSig(signalList.begin()); MissingETBase::Types::object_vector_t::const_iterator lSig(signalList.end()); for ( ; fSig != lSig; ++fSig ) { @@ -400,8 +332,7 @@ bool MissingETComponentMap_v1::setTracks(const MissingET* pMET,const IParticle* // if ( pCont == 0 ) // { printf("MissingETComponentMap::setTracks(...) - WARNING - cannot access track container (invalid NULL pointer), use %i words\n",(int)nTrack); } // else - nTrack = pCont->size(); - m_trackLinks.resize(nTrack,MissingETBase::Numerical::invalidLink()); + m_trackLinks.resize(pCont->size(), MissingETBase::Numerical::invalidLink()); } // empty track link list } // first track // all tracks refer to the same MET contribution diff --git a/Event/xAOD/xAODMissingET/Root/MissingETComponent_v1.cxx b/Event/xAOD/xAODMissingET/Root/MissingETComponent_v1.cxx index 1f5628aa1375fd2b47367866d174f4743d2c2e92..3c73024162813d7109968e1a7473e2d2001faeeb 100644 --- a/Event/xAOD/xAODMissingET/Root/MissingETComponent_v1.cxx +++ b/Event/xAOD/xAODMissingET/Root/MissingETComponent_v1.cxx @@ -54,18 +54,14 @@ bool MissingETComponent_v1::Weight::operator==(const Weight& wght) const ////////////////////////////////// MissingETComponent_v1::MissingETComponent_v1( bool createStore ) - : SG::AuxElement(), - m_lastObjectPointer( 0 ), - m_lastObjectIndex( MissingETBase::Numerical::invalidIndex() ) { + : SG::AuxElement(){ if( createStore ) createPrivateStore(); } MissingETComponent_v1::MissingETComponent_v1( const MissingET* pmetObj, MissingETBase::Types::bitmask_t sw ) - : SG::AuxElement(), - m_lastObjectPointer( 0 ), - m_lastObjectIndex( MissingETBase::Numerical::invalidIndex() ) { + : SG::AuxElement(){ createPrivateStore(); setMET( pmetObj ); @@ -76,9 +72,7 @@ MissingETComponent_v1::MissingETComponent_v1( const MissingET* pmetObj, const IParticle* pPart, double wpx, double wpy, double wet, MissingETBase::Types::bitmask_t sw ) - : SG::AuxElement(), - m_lastObjectPointer( 0 ), - m_lastObjectIndex( MissingETBase::Numerical::invalidIndex() ) { + : SG::AuxElement(){ createPrivateStore(); setMET( pmetObj ); @@ -90,9 +84,7 @@ MissingETComponent_v1::MissingETComponent_v1( const MissingET* pmetObj, const IParticle* pPart, const Weight& wght, MissingETBase::Types::bitmask_t sw ) - : SG::AuxElement(), - m_lastObjectPointer( 0 ), - m_lastObjectIndex( MissingETBase::Numerical::invalidIndex() ) { + : SG::AuxElement(){ createPrivateStore(); setMET( pmetObj ); @@ -102,21 +94,15 @@ MissingETComponent_v1::MissingETComponent_v1( const MissingET* pmetObj, MissingETComponent_v1::MissingETComponent_v1(const MissingETComponent_v1& compDescr) : SG::AuxElement() - , m_lastObjectPointer(compDescr.m_lastObjectPointer) - , m_lastObjectIndex(compDescr.m_lastObjectIndex) { this->makePrivateStore(&compDescr); } MissingETComponent_v1::MissingETComponent_v1(const MissingETComponent_v1& compDescr,MissingETBase::Types::bitmask_t sw) : SG::AuxElement() - , m_lastObjectPointer(compDescr.m_lastObjectPointer) - , m_lastObjectIndex(compDescr.m_lastObjectIndex) { this->makePrivateStore(compDescr); this->setStatusWord(sw); } MissingETComponent_v1& MissingETComponent_v1::operator=(const MissingETComponent_v1& compDescr) { if((&compDescr) != this) { - m_lastObjectPointer = compDescr.m_lastObjectPointer; - m_lastObjectIndex = compDescr.m_lastObjectIndex; this->setStatusWord(compDescr.statusWord()); this->setMetLink(compDescr.metLink()); this->setObjectLinks(compDescr.objectLinks()); @@ -226,16 +212,11 @@ bool MissingETComponent_v1::resetContrib() size_t MissingETComponent_v1::findIndex(const IParticle* pPart) const { - if ( m_lastObjectPointer != pPart ) - { - objlink_vector_t::const_iterator fLnk(this->objectLinks().begin()); - while ( fLnk != this->objectLinks().end() && *(*fLnk) != pPart ) { ++fLnk; } - if ( fLnk != this->objectLinks().end() ) - { m_lastObjectPointer = pPart; m_lastObjectIndex = std::distance(this->objectLinks().begin(),fLnk); } - else - { m_lastObjectPointer = (const IParticle*)0; m_lastObjectIndex = MissingETBase::Numerical::invalidIndex(); } - } - return m_lastObjectIndex; + objlink_vector_t::const_iterator fLnk(this->objectLinks().begin()); + while(fLnk != this->objectLinks().end() && *(*fLnk) != pPart){ ++fLnk; } + if(fLnk != this->objectLinks().end()) + return std::distance(this->objectLinks().begin(),fLnk); + return MissingETBase::Numerical::invalidIndex(); } ///////////// diff --git a/Event/xAOD/xAODMissingET/Root/MissingET_v1.cxx b/Event/xAOD/xAODMissingET/Root/MissingET_v1.cxx index 247b22d33c84f67a8530f1cf0f1762a6ef5978a6..dd3a22701fe48d7fd2b7e3414af8d1ff02fccf45 100644 --- a/Event/xAOD/xAODMissingET/Root/MissingET_v1.cxx +++ b/Event/xAOD/xAODMissingET/Root/MissingET_v1.cxx @@ -13,7 +13,10 @@ MissingET_v1::MissingET_v1( bool createStore ) if( createStore ) { createPrivateStore(); + setName(this->name()); } + else + m_nameHash = 0; } MissingET_v1::MissingET_v1( const std::string& name, @@ -51,8 +54,11 @@ MissingET_v1::MissingET_v1( const IParticle* particle, const std::string& name, // CHECK use makePrivateStore to control that behaviour ?? MissingET_v1::MissingET_v1(const MissingET_v1& met) - : SG::AuxElement() -{ this->makePrivateStore(&met); } + : SG::AuxElement() { + + this->makePrivateStore(&met); + updateHash(); +} MissingET_v1::~MissingET_v1() { } diff --git a/Event/xAOD/xAODMissingET/xAODMissingET/selection.xml b/Event/xAOD/xAODMissingET/xAODMissingET/selection.xml index 8b5125ec433da787f4f8a5e5fe6deaadba0fe0e8..344c91e0dffc75dbf6af20c44ead7a33ed2c4dd1 100644 --- a/Event/xAOD/xAODMissingET/xAODMissingET/selection.xml +++ b/Event/xAOD/xAODMissingET/xAODMissingET/selection.xml @@ -3,17 +3,14 @@ <!-- MissingET_v1 dictionaries: --> <class name="xAOD::MissingET_v1"> - <field name="m_nameHashPair" transient="true" /> + <field name="m_nameHash" transient="true" /> </class> <class name="DataVector<xAOD::MissingET_v1>" /> <class name="xAOD::MissingETContainer_v1" id="F49162FE-6BC0-49BC-A7DA-A792136BD939" /> <class name="xAOD::MissingETAuxContainer_v1" id="2F92EC94-8CD1-49F3-BCA4-3D78599D4D60" /> <!-- MissingETComponent_v1/MissingETComponentMap_v1 dictionaries: --> - <class name="xAOD::MissingETComponent_v1"> - <field name="m_lastObjectPointer" transient="true" /> - <field name="m_lastObjectIndex" transient="true" /> - </class> + <class name="xAOD::MissingETComponent_v1" /> <class name="xAOD::MissingETComponent_v1::Weight"> <field name="m_wpx" transient="true" /> <field name="m_wpy" transient="true" /> @@ -21,8 +18,6 @@ </class> <class name="DataVector<xAOD::MissingETComponent_v1>" /> <class name="xAOD::MissingETComponentMap_v1" id="994D9D32-820F-47B1-A54B-37C15CD0FD1E" > - <field name="m_lastMETObject" transient="true" /> - <field name="m_lastContribIndex" transient="true" /> <field name="m_clusterLinks" transient="true" /> <field name="m_trackLinks" transient="true" /> <field name="m_particleLinks" transient="true" /> @@ -31,11 +26,7 @@ <!-- MissingETAssociation_v1/MissingETAssociationMap_v1 dictionaries: --> <class name="xAOD::MissingETAssociation_v1"> - <field name="m_lastObjectPointer" transient="true" /> - <field name="m_lastObjectIndex" transient="true" /> <field name="m_objConstLinks" transient="true" /> - <field name="m_contribObjects" transient="true" /> - <field name="m_useObjectFlags" transient="true" /> <field name="m_override" transient="true" /> </class> <class name="xAOD::MissingETAssociation_v1::ConstVec"> @@ -46,12 +37,8 @@ <field name="m_sumpt" transient="true" /> </class> <class name="DataVector<xAOD::MissingETAssociation_v1>" /> - <class name="xAOD::MissingETAssociationMap_v1" id="E2EAA116-F03E-430E-B4EF-216AAF7DEEE8" > - <field name="m_jetConstLinks" transient="true" /> - <field name="m_lastRefJet" transient="true" /> - <field name="m_lastContribIndex" transient="true" /> - <field name="m_lastConstLink" transient="true" /> - <field name="m_miscAssocIndex" transient="true" /> + <class name="xAOD::MissingETAssociationMap_v1" id="E2EAA116-F03E-430E-B4EF-216AAF7DEEE8"> + <field name="m_jetConstLinks" transient="true" /> </class> <!-- Schema evolve aux container --> <class name="xAOD::MissingETAuxAssociationMap_v1" id="48EEF1CD-F937-445C-A09C-B978D152868E" /> diff --git a/Event/xAOD/xAODMissingET/xAODMissingET/versions/MissingETAssociation_v1.h b/Event/xAOD/xAODMissingET/xAODMissingET/versions/MissingETAssociation_v1.h index 05bbb4841b99c096608d7b1d379b21a666202a64..0b064821c8f05748d4c44079c2c312199648e49c 100644 --- a/Event/xAOD/xAODMissingET/xAODMissingET/versions/MissingETAssociation_v1.h +++ b/Event/xAOD/xAODMissingET/xAODMissingET/versions/MissingETAssociation_v1.h @@ -426,9 +426,6 @@ namespace xAOD private: std::map<const IParticle*,ConstVec> m_override; - static size_t m_objConstLinkReserve; - static size_t m_contribObjReserve; - }; // MissingETAssociation_v1 } diff --git a/Event/xAOD/xAODMissingET/xAODMissingET/versions/MissingETComponentMap_v1.h b/Event/xAOD/xAODMissingET/xAODMissingET/versions/MissingETComponentMap_v1.h index ed4ca44daff2cd2025999bb577e1c304327a46f3..9d3f8f01b5eb2b3c49290025141bfa45387a106c 100644 --- a/Event/xAOD/xAODMissingET/xAODMissingET/versions/MissingETComponentMap_v1.h +++ b/Event/xAOD/xAODMissingET/xAODMissingET/versions/MissingETComponentMap_v1.h @@ -97,7 +97,7 @@ namespace xAOD iterator find(MissingETBase::Types::bitmask_t src); size_t findIndex(const MissingET* pMET) const; size_t findIndex(const std::string& name) const; - size_t findIndex(MissingETBase::Types::bitmask_t sw) const; + size_t findIndex(MissingETBase::Types::bitmask_t src) const; /*! @brief Retrieve MissingET object by name * * @return Valid pointer to MissingET typed object representing a MET term. If the requested object cannot be found, @@ -208,15 +208,15 @@ namespace xAOD /*! @name Internal data for local cache */ /*!@{*/ - mutable signal_vector_t m_clusterLinks; /*!< @brief Store for linked cluuster signal information lookup - * @copydetails signal_vector_t - */ - mutable signal_vector_t m_trackLinks; /*!< @brief Store for linked track signal information lookup - * @copydetails signal_vector_t - */ - mutable particle_map_t m_particleLinks; /*!< @brief Store for linked physics object information lookup - * @copydetails particle_map_t - */ + signal_vector_t m_clusterLinks; /*!< @brief Store for linked cluuster signal information lookup + * @copydetails signal_vector_t + */ + signal_vector_t m_trackLinks; /*!< @brief Store for linked track signal information lookup + * @copydetails signal_vector_t + */ + particle_map_t m_particleLinks; /*!< @brief Store for linked physics object information lookup + * @copydetails particle_map_t + */ /*!@}*/ /*! @name Internal functions for local cache handling */ @@ -247,7 +247,7 @@ namespace xAOD * * @note This method does not add yet unused signal objects to the signal link list, as this decision is controlled by the specific MET reconstruction tool. */ - bool f_checkObjectUsage(MissingETBase::Types::object_vector_t& sig,signal_vector_t& signalLinks) const ; + bool f_checkObjectUsage(MissingETBase::Types::object_vector_t& sig, const signal_vector_t& signalLinks) const ; /*! @brief Check physics object usage * * @return @c true if any of the physics objects in the input list is already marked as used. In addition, all used objects are removed from the input (physics) object list. @@ -258,7 +258,7 @@ namespace xAOD * * @note This method does not add yet unused physics objects to the signal link list, as this decision is controlled by the specific MET reconstruction tool. */ - bool f_checkObjectUsage(MissingETBase::Types::object_vector_t& objects,particle_map_t& physicsLinks) const; + bool f_checkObjectUsage(MissingETBase::Types::object_vector_t& objects, const particle_map_t& physicsLinks) const; /*! @brief Fill the lookup cache from the composition map data content */ void f_fillLookupCache(); /*! @brief Clear the lookup cache */ @@ -281,52 +281,6 @@ namespace xAOD while ( fSign != sig.end() ) { if ( (*fSign)->type() != OBJTYPE ) { fSign = sig.erase(fSign); } else { ++fSign; } } return !sig.empty(); } - /*!@}*/ - - /*! @name Internal lookup cache */ - /*!@{*/ - /*!@}*/ - - /*! @name Internal find methods for constant access */ - /*!@{*/ - /*! @brief Find contribution by MET object pointer - * - * This method finds a xAOD::MissingETComponent_v1 object linked to the specified xAOD::MissingET object. It is invoked internally by find(const MissingET*). - * It uses an internal cache to determine if this MET object has been found in the latest invocation of the find method, and returns without further action in this case. - * If a different MET object is searched for, it initiates a linear search and updates the internal cache with the new pointer (will be NULL if referenced MET object - * not found) and the datawords storing the const_iterator and the iterator referencing the non-modifiable and modifiable xAOD::MissingETComponent_v1 object in the - * composition map, respectively (both iterators will be set to the corresponding end iterator if the MET object is not in the composition map). - * - * @return Valid const iterator referencing the MissingETComponent_v1 object linking ot the requested MET object. If this MET object is not in the list, - * MissingETComponentMap_v1::end() is returned. - * - * @param[in] pMET pointer to non-modifiable MissingET object to be found in the composition map. - */ - const_iterator f_findConst(const MissingET* pMET) const; - /*! @brief Find contribution by MET object name - * - * This method finds a xAOD::MissingETComponent_v1 object linked to the specified xAOD::MissingET object. It is invoked internally by find(const std::string&). - * It uses an internal cache to determine if this MET object has been found in the latest invocation of the find method, and returns without further action in this case. - * If a different MET object is searched for, it initiates a linear search and updates the internal cache with the new pointer (will be NULL if referenced MET object - * not found) and the datawords storing the const_iterator and the iterator referencing the non-modifiable and modifiable xAOD::MissingETComponent_v1 object in the - * composition map, respectively (both iterators will be set to the corresponding end iterator if the MET object is not in the composition map). - * - * - * @return Valid const iterator referencing the MissingETComponent_v1 object linking ot the requested MET object. If this MET object is not in the list, - * MissingETComponentMap_v1::end() is returned. - * - * @param[in] name reference to the non-modifiable data word storing the name of the requested MET object. - */ - const_iterator f_findConst(const std::string& name) const; - const_iterator f_findConst(MissingETBase::Types::bitmask_t src) const; - void f_setConstCache(const_iterator fCont) const; - /*!@}*/ - - iterator f_find(const MissingET* pMET); - iterator f_find(const std::string& name); - iterator f_find(MissingETBase::Types::bitmask_t src); - void f_setCache(iterator fCont); - void resetCache() const; const MissingET* f_retrieveMissingETExcl(MissingETBase::Types::bitmask_t src) const; const MissingET* f_retrieveMissingETExcl(MissingETBase::Types::bitmask_t src,MissingETBase::Types::bitmask_t sw) const; @@ -335,14 +289,8 @@ namespace xAOD private: - mutable const MissingET* m_lastMETObject; - mutable size_t m_lastContribIndex; - static size_t m_clusterLinkReserve; static size_t m_trackLinkReserve; - static size_t m_maxClusterSize; - static size_t m_maxTrackSize; - static size_t m_maxSignalSize; }; // class xAOD::MissingETComponentMap_v1 } // namespace xAOD diff --git a/Event/xAOD/xAODMissingET/xAODMissingET/versions/MissingETComponentMap_v1.icc b/Event/xAOD/xAODMissingET/xAODMissingET/versions/MissingETComponentMap_v1.icc index 128a73adac92024676a9a3fb018e118cfaf56f01..0e7de513d5b6caaa5e647f5c0c3585f618425f03 100644 --- a/Event/xAOD/xAODMissingET/xAODMissingET/versions/MissingETComponentMap_v1.icc +++ b/Event/xAOD/xAODMissingET/xAODMissingET/versions/MissingETComponentMap_v1.icc @@ -9,39 +9,34 @@ // Inlined Overrides of DV methods // //////////////////////////////////////// -inline void xAOD::MissingETComponentMap_v1::resetCache() const -{ - m_lastMETObject = 0; - m_lastContribIndex = MissingETBase::Numerical::invalidIndex(); -} inline void xAOD::MissingETComponentMap_v1::resize(xAOD::MissingETComponentMap_v1::size_type sz) -{ this->resetCache(); DataVector<MissingETComponent_v1>::resize(sz); } +{ DataVector<MissingETComponent_v1>::resize(sz); } inline void xAOD::MissingETComponentMap_v1::pop_back() -{ this->resetCache(); DataVector<MissingETComponent_v1>::pop_back(); } +{ DataVector<MissingETComponent_v1>::pop_back(); } inline void xAOD::MissingETComponentMap_v1::sort() -{ this->resetCache(); DataVector<MissingETComponent_v1>::sort(); } +{ DataVector<MissingETComponent_v1>::sort(); } template<class COMPARE> inline void xAOD::MissingETComponentMap_v1::sort(COMPARE comp) -{ this->resetCache(); DataVector<MissingETComponent_v1>::sort(comp); } +{ DataVector<MissingETComponent_v1>::sort(comp); } inline void xAOD::MissingETComponentMap_v1::clear() -{ this->resetCache(); DataVector<MissingETComponent_v1>::clear(); } +{ DataVector<MissingETComponent_v1>::clear(); } inline void xAOD::MissingETComponentMap_v1::clear (SG::OwnershipPolicy ownPolicy) -{ this->resetCache(); DataVector<MissingETComponent_v1>::clear(ownPolicy); } +{ DataVector<MissingETComponent_v1>::clear(ownPolicy); } inline void xAOD::MissingETComponentMap_v1::clear (SG::OwnershipPolicy ownPolicy,SG::IndexTrackingPolicy trackIndices) -{ this->resetCache(); DataVector<MissingETComponent_v1>::clear(ownPolicy,trackIndices); } +{ DataVector<MissingETComponent_v1>::clear(ownPolicy,trackIndices); } inline xAOD::MissingETComponentMap_v1::iterator xAOD::MissingETComponentMap_v1::erase(xAOD::MissingETComponentMap_v1::iterator position) -{ this->resetCache(); return DataVector<MissingETComponent_v1>::erase(position); } +{ return DataVector<MissingETComponent_v1>::erase(position); } inline xAOD::MissingETComponentMap_v1::iterator xAOD::MissingETComponentMap_v1::erase(xAOD::MissingETComponentMap_v1::iterator first, xAOD::MissingETComponentMap_v1::iterator last) -{ this->resetCache(); return DataVector<MissingETComponent_v1>::erase(first, last); } +{ return DataVector<MissingETComponent_v1>::erase(first, last); } /////////////////////////////////////////////////////////////// diff --git a/Event/xAOD/xAODMissingET/xAODMissingET/versions/MissingETComponent_v1.h b/Event/xAOD/xAODMissingET/xAODMissingET/versions/MissingETComponent_v1.h index 65fb6844f8d1ecbf9d1c849a301005542563d0c0..317ec5373caa911b886109c9b80c14f244d18240 100644 --- a/Event/xAOD/xAODMissingET/xAODMissingET/versions/MissingETComponent_v1.h +++ b/Event/xAOD/xAODMissingET/xAODMissingET/versions/MissingETComponent_v1.h @@ -254,12 +254,6 @@ namespace xAOD template<class POBJ,class LINK> void f_setObject(const POBJ* pObj,LINK& elemLink); template<class LINK> bool f_setLink(LINK& elemLink); /*!@}*/ - private: - /*! @name Cache remembering the previous search result */ - /*!@{*/ - mutable const IParticle* m_lastObjectPointer; /*!< @brief Pointer to last searched object */ - mutable size_t m_lastObjectIndex; /*!< @brief Index of last searched object in list */ - /*!@}*/ }; // MissingETComponenet_v1 } diff --git a/Event/xAOD/xAODMissingET/xAODMissingET/versions/MissingET_v1.h b/Event/xAOD/xAODMissingET/xAODMissingET/versions/MissingET_v1.h index 650477cbbe7227407b1d0bdd5d409e326a3770b3..854abb445508edd76135c5e14cd719002f1f0470 100644 --- a/Event/xAOD/xAODMissingET/xAODMissingET/versions/MissingET_v1.h +++ b/Event/xAOD/xAODMissingET/xAODMissingET/versions/MissingET_v1.h @@ -57,13 +57,14 @@ namespace xAOD /*!@{*/ const std::string& name() const; /*!< @brief MET object name */ MissingETBase::Types::bitmask_t source() const; /*!< @brief MET object source tag */ - const std::size_t& nameHash() const; /*!< @brief Return hash associated to the MET object name */ + std::size_t nameHash() const; /*!< @brief Return hash associated to the MET object name */ /*!@}*/ /*! @name Identifier setters */ /*!@{*/ void setName(const std::string& name); /*!< @brief Set the name of the MET object */ void setSource(MissingETBase::Types::bitmask_t src); /*!< @brief Set the source of the MET object */ + void updateHash(); /*!< @brief Update the hash to match the current name */ /*!@}*/ /*! @name Manipulating the kinematic data */ @@ -107,11 +108,12 @@ namespace xAOD double& f_mpy(); /*!< @brief Returns reference to @f$ p_{y} @f$ store */ double& f_sumet(); /*!< @brief Returns reference to @f$ \Sigma E_{\rm T} @f$ store */ std::string& f_name(); /*!< @brief Returns reference to MET object name store */ + const std::string& f_nameConst(); /*!< @brief Returns const reference to the MET object name store*/ MissingETBase::Types::bitmask_t& f_source(); /*!< @brief Returns reference to MET object source store */ /*!@}*/ private: - mutable std::pair< std::string , std::size_t> m_nameHashPair;/*!< @brief Stores the hash function for the current f_name string */ + std::size_t m_nameHash;/*!< @brief Stores the hash for the current f_name string */ }; } diff --git a/Event/xAOD/xAODMissingET/xAODMissingET/versions/MissingET_v1.icc b/Event/xAOD/xAODMissingET/xAODMissingET/versions/MissingET_v1.icc index 51543dbd5dce5c2d5c9b967f825bed3f6aaf1e62..d50df80e48a58d874645cd3984ff5ac69280ed7b 100644 --- a/Event/xAOD/xAODMissingET/xAODMissingET/versions/MissingET_v1.icc +++ b/Event/xAOD/xAODMissingET/xAODMissingET/versions/MissingET_v1.icc @@ -16,13 +16,7 @@ inline double xAOD::MissingET_v1::mpy() const { static SG::AuxElement::Accesso inline double xAOD::MissingET_v1::sumet() const { static SG::AuxElement::Accessor<double> acc("sumet"); return acc(*this); } inline const std::string& xAOD::MissingET_v1::name() const { static SG::AuxElement::Accessor<std::string> acc("name"); return acc(*this); } -//inline const std::string& xAOD::MissingET_v1::name() const { return m_nameHashPair.first; }; -inline const std::size_t& xAOD::MissingET_v1::nameHash() const { - if(!name().empty() && m_nameHashPair.second==0) { - m_nameHashPair = {name() , std::hash<std::string>()(name())}; - } - return m_nameHashPair.second; -} +inline std::size_t xAOD::MissingET_v1::nameHash() const { return m_nameHash; } inline MissingETBase::Types::bitmask_t xAOD::MissingET_v1::source() const { static SG::AuxElement::Accessor<MissingETBase::Types::bitmask_t> acc("source"); return acc(*this); } //////////////////////////////////////////// @@ -34,16 +28,19 @@ inline double& xAOD::MissingET_v1::f_mpy() { static SG::AuxElement::Accessor<d inline double& xAOD::MissingET_v1::f_sumet() { static SG::AuxElement::Accessor<double> acc("sumet"); return acc(*this); } inline std::string& xAOD::MissingET_v1::f_name() { static SG::AuxElement::Accessor<std::string> acc("name"); return acc(*this); } +inline const std::string& xAOD::MissingET_v1::f_nameConst() { static SG::AuxElement::ConstAccessor<std::string> acc("name"); return acc(*this); } inline MissingETBase::Types::bitmask_t& xAOD::MissingET_v1::f_source() { static SG::AuxElement::Accessor<MissingETBase::Types::bitmask_t> acc("source"); return acc(*this); } inline void xAOD::MissingET_v1::setMpx(double mpx) { this->f_mpx() = mpx; } inline void xAOD::MissingET_v1::setMpy(double mpy) { this->f_mpy() = mpy; } inline void xAOD::MissingET_v1::setSumet(double sumet) { this->f_sumet() = sumet; } - -inline void xAOD::MissingET_v1::setName(const std::string& name) { this->f_name() = name; - m_nameHashPair = {name , std::hash<std::string>()(name)} ; +inline void xAOD::MissingET_v1::setName(const std::string& name) { + this->f_name() = name; + updateHash(); } + +inline void xAOD::MissingET_v1::updateHash() { m_nameHash = std::hash<std::string>()(this->f_nameConst()); } inline void xAOD::MissingET_v1::setSource(MissingETBase::Types::bitmask_t src) { this->f_source() = src; } /////////////////////////////////////////////////// diff --git a/Event/xAOD/xAODMissingETAthenaPool/src/xAODMissingETContainerCnv.cxx b/Event/xAOD/xAODMissingETAthenaPool/src/xAODMissingETContainerCnv.cxx index fea90d86c9464a6e3d740aa70e9aaf78510b5d9e..4e1cd4b7333f0c5a4e0a5d201682eaf2772c0077 100644 --- a/Event/xAOD/xAODMissingETAthenaPool/src/xAODMissingETContainerCnv.cxx +++ b/Event/xAOD/xAODMissingETAthenaPool/src/xAODMissingETContainerCnv.cxx @@ -77,6 +77,7 @@ xAOD::MissingETContainer* xAODMissingETContainerCnv::createTransient() { if( compareClassGuid( v1_guid ) ) { xAOD::MissingETContainer* c = poolReadObject< xAOD::MissingETContainer >(); setStoreLink( c, m_key ); + for(xAOD::MissingET* metObj : *c) metObj->updateHash(); return c; }