18 m_trigDecTool.setTypeAndName(
"Trig::TrigDecisionTool/TrigDecisionTool");
28 return StatusCode::SUCCESS;
32 const std::vector<const xAOD::IParticle *> &recoObjects,
33 const std::string &chain,
34 double matchThreshold,
37 if (recoObjects.size() == 0)
42 using VecLinkInfo_t = std::vector<IPartLinkInfo_t>;
52 std::vector<std::map<std::pair<uint32_t, uint32_t>,
bool>> cachedComparisons(recoObjects.size());
70 for (IPartLinkInfo_t &linkInfo : features)
72 if (!linkInfo.isValid())
74 ATH_MSG_ERROR(
"Chain " << chainName <<
" has invalid link info!");
75 throw std::runtime_error(
"Bad link info");
87 if (combinations.size() < recoObjects.size())
90 "Chain " << chainName <<
" (matching pattern " << chain <<
") has too few objects ("
91 << combinations.size() <<
") to match the number of provided reco objects (" << recoObjects.size() <<
")");
95 for (
const VecLinkInfo_t &combination : combinations)
98 std::vector<std::size_t> onlineIndices(combination.size());
99 std::iota(onlineIndices.begin(), onlineIndices.end(), 0);
103 for (std::size_t recoIdx = 0; recoIdx < recoObjects.size(); ++recoIdx)
105 std::size_t onlineIdx = onlineIndices[recoIdx];
107 recoObjects[recoIdx],
108 combination[onlineIdx].link,
109 chainInfo.second[onlineIdx],
110 cachedComparisons[recoIdx],
119 }
while (std::next_permutation(onlineIndices.begin(), onlineIndices.end()));
129 const std::string &chain,
130 double matchThreshold,
133 std::vector<const xAOD::IParticle *> tmpVec{&recoObject};
134 return match(tmpVec, chain, matchThreshold, rerun);
141 std::map<std::pair<uint32_t, uint32_t>,
bool> &cache,
142 double scoreThreshold)
const
149 std::pair<uint32_t, uint32_t> linkIndices(onlineLink.
persKey(), onlineLink.
persIndex());
150 auto cacheItr = cache.find(linkIndices);
151 if (cacheItr == cache.end())
154 ATH_MSG_DEBUG(
"Match online " << onlineType <<
" to offline " << reco->type());
155 bool match = onlineType == reco->type();
163 throw std::runtime_error(
"Failed to cast to egamma object");
168 ATH_MSG_WARNING(
"Cannot retrieve egamma object's primary calorimeter cluster, will match to the egamma object");
173 cacheItr = cache.insert(std::make_pair(linkIndices,
match)).first;
175 return cacheItr->second;
180 std::lock_guard<std::mutex> guard(m_chainInfoMutex);
181 auto cacheItr = m_chainInfoCache.find(chain);
182 if (cacheItr == m_chainInfoCache.end())
191 info.first.push_back(0);
195 info.first.push_back(legInfo.multiplicity);
196 for (std::size_t idx = 0; idx < legInfo.multiplicity; ++idx)
197 info.second.push_back(
type);
200 cacheItr = m_chainInfoCache.insert(std::make_pair(chain, std::move(info))).first;
202 return cacheItr->second;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Helper class that provides access to information about individual legs.
stored_index_type persIndex() const
Return the index of the link.
sgkey_t persKey() const
Return the SG key that we reference, as a hash.
ElementLink implementation for ROOT usage.
bool isValid() const
Test to see if the link can be dereferenced.
std::vector< std::string > getListOfTriggers() const
Class providing the definition of the 4-vector interface.
Combinations buildCombinations(const std::string &chainName, const std::vector< LinkInfo< xAOD::IParticleContainer > > &features, const std::vector< std::size_t > &legMultiplicities, const std::function< bool(const std::vector< LinkInfo< xAOD::IParticleContainer > > &)> &filter)
Produce the combinations for a set of features.
@ UniqueObjects
Do not allow any repeated objects.
static const unsigned int allowResurrectedDecision
static const unsigned int Physics
The common trigger namespace for trigger analysis tools.
ObjectType
Type of objects that have a representation in the xAOD EDM.
@ Photon
The object is a photon.
@ Other
An object not falling into any of the other categories.
@ CaloCluster
The object is a calorimeter cluster.
@ Electron
The object is an electron.
Egamma_v1 Egamma
Definition of the current "egamma version".
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.
Struct containing information on each leg of a chain.
Helper to keep a Decision object, ElementLink and ActiveState (with respect to some requested ChainGr...