ATLAS Offline Software
Loading...
Searching...
No Matches
MissingETComponentMap_v1.h
Go to the documentation of this file.
1// -*- c++ -*-
2
3/*
4 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
5*/
6
7#ifndef XAODMISSINGET_VERSIONS_MISSINGETCOMPONENTMAP_V1_H
8#define XAODMISSINGET_VERSIONS_MISSINGETCOMPONENTMAP_V1_H
9
11
12#include "xAODBase/ObjectType.h"
13
17
18#include <string>
19#include <vector>
20#include <map>
21
22namespace xAOD
23{
24 class MissingETComponentMap_v1 : public DataVector<MissingETComponent_v1>
25 {
26 public:
27
36
46 const_iterator find(const MissingET* pMET) const;
57 const_iterator find(const std::string& name) const;
76 iterator find(const MissingET* pMET);
87 iterator find(const std::string& name);
99 size_t findIndex(const MissingET* pMET) const;
100 size_t findIndex(const std::string& name) const;
109 const MissingET* retrieveMissingET(const std::string& name) const;
120 const MissingET* retrieveMissingET(MissingETBase::Types::bitmask_t src,bool excl=false) const;
132
133 public:
134
161 //
162 bool addObjects(const MissingET* pMET,const IParticle* pPart,const MissingETBase::Types::object_vector_t& signalList,
164 bool setClusters(const MissingET* pMET,const IParticle* pPart,const MissingETBase::Types::object_vector_t& signalList);
165 bool setTracks(const MissingET* pMET,const IParticle* pPart,const MissingETBase::Types::object_vector_t& signalList);
166 bool setObjects(const MissingET* pMET,const IParticle* pPart,const MissingETBase::Types::object_vector_t& objectList);
167 size_t getComponentIndex(const IParticle* pPart) const;
168 size_t getObjectIndex(const IParticle* pPart) const;
170
171 /* override base DataVector methods that can remove elements
172 * in order to invalidate the cache
173 */
175 void pop_back();
176 void clear();
177 void sort();
178 template <class COMPARE> void sort(COMPARE comp);
183
184 protected:
185
188 typedef size_t signal_key_t;
189 typedef const IParticle* particle_key_t;
195 typedef std::vector<indexedlink_t> signal_vector_t;
201 typedef std::map<particle_key_t,indexedlink_t> particle_map_t;
209
222
225 template<int N> size_t f_getIndex(const IParticle* pPart) const
226 {
227 // check on cluster signal
228 if ( pPart->type() == Type::CaloCluster )
229 { size_t idx(pPart->index()); return idx < m_clusterLinks.size() ? std::get<N>( m_clusterLinks.at(idx)) : MissingETBase::Numerical::invalidIndex(); }
230 // check on track signal
231 if ( pPart->type() == Type::TrackParticle )
232 { size_t idx(pPart->index()); return idx < m_trackLinks.size() ? std::get<N>(m_trackLinks.at(idx)) : MissingETBase::Numerical::invalidIndex(); }
233 //
234 particle_map_t::const_iterator fPart(m_particleLinks.find(pPart));
235 return fPart != m_particleLinks.end() ? std::get<N>(fPart->second) : MissingETBase::Numerical::invalidIndex();
236 }
237
238
262 bool f_checkObjectUsage(MissingETBase::Types::object_vector_t& objects, const particle_map_t& physicsLinks) const;
264 void f_fillLookupCache();
266 void f_clearLookupCache();
268 void f_setupLookupCache(signal_vector_t& signalLinks,size_t reserve);
278 template<int OBJTYPE>
280 {
281 MissingETBase::Types::object_vector_t::iterator fSign(sig.begin());
282 while ( fSign != sig.end() ) { if ( (*fSign)->type() != OBJTYPE ) { fSign = sig.erase(fSign); } else { ++fSign; } }
283 return !sig.empty();
284 }
285
290
291 private:
292
293 static const size_t m_clusterLinkReserve =10000;
294 static const size_t m_trackLinkReserve =10000;
295
296 }; // class xAOD::MissingETComponentMap_v1
297} // namespace xAOD
298
299#include "xAODCore/BaseInfo.h"
301
303#endif
#define SG_BASE(D, B)
Declare that class D derives from class B.
An STL vector of pointers that by default owns its pointed-to elements.
static Double_t sz
Derived DataVector<T>.
Definition DataVector.h:795
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
typename DataVectorBase< MissingETComponent_v1 >::Base::size_type size_type
Definition DataVector.h:814
DataModel_detail::iterator< DataVector > iterator
Definition DataVector.h:842
DataVector(SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS, SG::IndexTrackingPolicy trackIndices=SG::DEFAULT_TRACK_INDICES)
SG::OwnershipPolicy ownPolicy() const
size_t index() const
Return the index of this element within its container.
Class providing the definition of the 4-vector interface.
virtual Type::ObjectType type() const =0
The type of the object as a simple enumeration.
bool checkUsage(const IParticle *pPart, MissingETBase::UsageHandler::Policy p=MissingETBase::UsageHandler::OnlyCluster) const
Check if a given object is already used in MET.
particle_map_t m_particleLinks
Store for linked physics object information lookup.
size_t signal_key_t
Key type for signals (clusters, tracks) is type of index in container.
const MissingET * retrieveMissingET(const std::string &name) const
Retrieve MissingET object by name.
bool setTracks(const MissingET *pMET, const IParticle *pPart, const MissingETBase::Types::object_vector_t &signalList)
void clear(SG::OwnershipPolicy ownPolicy, SG::IndexTrackingPolicy trackIndices)
void f_setupLookupCache(signal_vector_t &signalLinks, size_t reserve)
Set up the signal object lookup.
bool f_checkObjectUsage(MissingETBase::Types::object_vector_t &sig, const signal_vector_t &signalLinks) const
Check signal object usage.
bool addObjects(const MissingET *pMET, const IParticle *pPart, const MissingETBase::Types::object_vector_t &signalList, MissingETBase::UsageHandler::Policy p=MissingETBase::UsageHandler::OnlyCluster)
signal_vector_t m_clusterLinks
Store for linked cluuster signal information lookup.
MissingETComponentMap_v1(SG::OwnershipPolicy own=SG::OWN_ELEMENTS, SG::IndexTrackingPolicy trackIndices=SG::DEFAULT_TRACK_INDICES)
Default constructor.
std::vector< indexedlink_t > signal_vector_t
Indexed list type for signal object link locations.
bool setClusters(const MissingET *pMET, const IParticle *pPart, const MissingETBase::Types::object_vector_t &signalList)
signal_vector_t m_trackLinks
Store for linked track signal information lookup.
void f_clearLookupCache()
Clear the lookup cache.
const_iterator find(const MissingET *pMET) const
Find MET object referenced by pointer.
void clear(SG::OwnershipPolicy ownPolicy)
bool f_extractSignal(MissingETBase::Types::object_vector_t &sig) const
Signal type extractor.
size_t getObjectIndex(const IParticle *pPart) const
size_t getComponentIndex(const IParticle *pPart) const
iterator erase(iterator first, iterator last)
const MissingET * f_retrieveMissingETIncl(MissingETBase::Types::bitmask_t src) const
const IParticle * particle_key_t
Key type for physics objects is the base pointer type of these objects.
void f_fillLookupCache()
Fill the lookup cache from the composition map data content.
iterator erase(iterator position)
size_t findIndex(const MissingET *pMET) const
MissingETBase::Types::indexedlink_t indexedlink_t
Type for the description of the link locations.
bool setObjects(const MissingET *pMET, const IParticle *pPart, const MissingETBase::Types::object_vector_t &objectList)
const MissingET * f_retrieveMissingETExcl(MissingETBase::Types::bitmask_t src) const
virtual ~MissingETComponentMap_v1()
Base class destructor.
size_t f_getIndex(const IParticle *pPart) const
std::map< particle_key_t, indexedlink_t > particle_map_t
Map type for physics object.
std::vector< const xAOD::IParticle * > object_vector_t
Vector of object type.
uint64_t bitmask_t
Type for status word bit mask.
std::tuple< size_t, size_t > indexedlink_t
Type for links defined as index pairs.
@ OnlyCluster
CaloCluster based only.
@ DEFAULT_TRACK_INDICES
Default value.
OwnershipPolicy
@ OWN_ELEMENTS
this data object owns its elements
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
MissingET_v1 MissingET
Version control by type defintion.
static size_t invalidIndex()
Access invalid index indicator.