Skip to content
Snippets Groups Projects
Commit a74fbf34 authored by Jon Burr's avatar Jon Burr
Browse files

Correct errors in the IPartCombItr, add uniqueObjects filter

parent 650549f4
6 merge requests!58791DataQualityConfigurations: Modify L1Calo config for web display,!46784MuonCondInterface: Enable thread-safety checking.,!46776Updated LArMonitoring config file for WD to match new files produced using MT,!45405updated ART test cron job,!42417Draft: DIRE and VINCIA Base Fragments for Pythia 8.3,!38981R3 trigger matching
......@@ -31,6 +31,7 @@ namespace Trig
R3MatchingTool::R3MatchingTool(const std::string &name) : asg::AsgTool(name)
{
m_trigDecTool.setTypeAndName("Trig::TrigDecisionTool/TrigDecisionTool");
declareProperty("TrigDecisionTool", m_trigDecTool, "The trigger decision tool");
}
......@@ -72,20 +73,34 @@ namespace Trig
const Trig::ChainGroup *chainGroup = m_trigDecTool->getChainGroup(chain);
for (const std::string &chainName : chainGroup->getListOfTriggers())
{
if (msgLvl(MSG::DEBUG))
ATH_MSG_DEBUG("Chain " << chainName << " was passed? " << m_trigDecTool->isPassed(chainName));
// Now we have to build up combinations
// TODO - right now we use a filter that passes everything through.
// TODO - right now we use a filter that passes everything that isn't pointer-equal.
// This will probably need to be fixed to something else later - at least the unique RoI filter
TrigCompositeUtils::Combinations combinations(TrigCompositeUtils::FilterType::All);
const TrigConf::HLTChain *chainInfo = m_trigDecTool->ExperimentalAndExpertMethods()->getChainConfigurationDetails(chainName);
std::vector<std::size_t> multiplicities = chainInfo->leg_multiplicities();
combinations.reserve(multiplicities.size());
for (std::size_t legIdx = 0; legIdx < multiplicities.size(); ++legIdx)
// Get all the features for the chain
VecLinkInfo_t chainFeatures = m_trigDecTool->features<xAOD::IParticleContainer>(chainName, condition);
ATH_MSG_VERBOSE("Chain " << chainName << " has " << chainFeatures.size() << " features and " << multiplicities.size() << " legs with multiplicities, nFeatures: ");
if (multiplicities.size() == 1)
{
HLT::Identifier legID = TrigCompositeUtils::createLegName(chainName, legIdx);
combinations.addLeg(
multiplicities.at(legIdx),
m_trigDecTool->features<xAOD::IParticleContainer>(legID.name(), condition));
ATH_MSG_VERBOSE(" :" << multiplicities.at(0) << ", " << chainFeatures.size());
combinations.addLeg(multiplicities.at(0), std::move(chainFeatures));
}
else
for (std::size_t legIdx = 0; legIdx < multiplicities.size(); ++legIdx)
{
HLT::Identifier legID = TrigCompositeUtils::createLegName(chainName, legIdx);
VecLinkInfo_t legFeatures;
for (const IPartLinkInfo_t &info : chainFeatures)
if (TrigCompositeUtils::isAnyIDPassing(info.source, {legID.numeric()}))
legFeatures.push_back(info);
ATH_MSG_VERBOSE(legID.name() << " (" << legID.numeric() << "): " << multiplicities.at(legIdx) << ", " << legFeatures.size());
combinations.addLeg(multiplicities.at(legIdx), std::move(legFeatures));
}
// Warn once per call if one of the chain groups is too small to match anything
if (combinations.size() < recoObjects.size())
{
......@@ -104,11 +119,13 @@ namespace Trig
{
bool match = true;
for (std::size_t recoIdx = 0; recoIdx < recoObjects.size(); ++recoIdx)
{
if (!matchObjects(recoObjects[recoIdx], combination[onlineIndices[recoIdx]].link, cachedComparisons[recoIdx], matchThreshold))
{
match = false;
break;
}
}
if (match)
return true;
} while (std::next_permutation(onlineIndices.begin(), onlineIndices.end()));
......@@ -117,45 +134,6 @@ namespace Trig
// If we reach here we've tried all combinations from all chains in the group and none of them matched
return false;
// if (recoObjects.size() != 1)
// {
// ATH_MSG_WARNING("Matching of multiple objects is not yet supported!");
// return false;
// }
// // This has to assume that the last IParticle feature in each chain is the
// // correct one - I don't *think* this will cause any issues.
// // Unlike with TEs, each chain should build in nodes that it actually uses.
// // This means that we don't need anything clever for the etcut triggers any more (for example)
// VecLinkInfo features = m_trigDecTool->features<xAOD::IParticleContainer>(
// chain,
// rerun ? TrigDefs::Physics | TrigDefs::allowResurrectedDecision : TrigDefs::Physics);
// ATH_MSG_DEBUG("Found " << features.size() << " features for chain group " << chain);
// // TODO:
// // Right now we are only looking at single object chains, so we only need
// // to find a single match for one reco-object.
// // Longer term we need to deal with combinations so this gets harder
// const xAOD::IParticle &recoObject = *recoObjects.at(0);
// for (const IPartLinkInfo_t &info : features)
// {
// if (!info.link.isValid())
// {
// // This could result in false negatives...
// ATH_MSG_WARNING("Invalid link to trigger feature for chain " << chain);
// continue;
// }
// const xAOD::IParticle &trigObject = **info.link;
// if (fastDR(
// recoObject.eta(),
// recoObject.phi(),
// trigObject.eta(),
// trigObject.phi(),
// matchThreshold))
// // Once we find one match, that is enough
// return true;
// }
// // If we get here then there was no good match
// return false;
}
bool R3MatchingTool::match(
......
......@@ -4,6 +4,15 @@
namespace TrigCompositeUtils
{
bool uniqueObjects(const std::vector<LinkInfo<xAOD::IParticleContainer>> &links)
{
std::set<const xAOD::IParticle *> seen;
for (const auto &info : links)
if (!seen.insert(*info.link).second)
return false;
return true;
}
bool uniqueRoIs(const std::vector<LinkInfo<xAOD::IParticleContainer>> &links)
{
std::set<std::pair<uint32_t, uint32_t>> seen;
......@@ -23,6 +32,8 @@ namespace TrigCompositeUtils
{
case FilterType::All:
return [](const std::vector<LinkInfo<xAOD::IParticleContainer>> &) { return true; };
case FilterType::UniqueObjects:
return uniqueObjects;
case FilterType::UniqueRoIs:
return uniqueRoIs;
default:
......@@ -83,9 +94,8 @@ namespace TrigCompositeUtils
for (std::size_t ii = 0; ii < idxItr.size(); ++ii)
*(outItr++) = LinkInfo<xAOD::IParticleContainer>{};
else
std::transform(
idxItr->begin(), idxItr->end(), outItr,
[begin = itrPair.second](std::size_t idx) { return *(begin + idx); });
for (std::size_t idx : *idxItr)
*(outItr++) = *(itrPair.second + idx);
}
// make sure that the starting set makes sense
if (!exhausted() && !m_filter(m_current))
......@@ -124,13 +134,13 @@ namespace TrigCompositeUtils
{
KFromNItr &idxItr = backItr->first;
step += idxItr.size();
if (!backItr++->first.exhausted())
if (!(++backItr->first).exhausted())
{
// This is the starting point for a good combination
// We need to update the current value
auto outItr = m_current.end() - step;
for (std::size_t idx : *idxItr)
*(outItr) = *(backItr->second + idx);
*(outItr++) = *(backItr->second + idx);
// Any iterators we passed by up to this point were exhausted so we have
// to reset them before we use their values
......
......@@ -22,11 +22,11 @@ namespace TrigCompositeUtils
Combinations(
const std::vector<std::size_t> &legMultiplicities,
const std::vector<VecLInfo_t> &legFeatures,
FilterType filter = FilterType::All);
FilterType filter = FilterType::UniqueObjects);
Combinations(const std::function<bool(const VecLInfo_t &)> &filter);
Combinations(FilterType filter = FilterType::All);
Combinations(FilterType filter = FilterType::UniqueObjects);
void reserve(std::size_t capacity);
......
......@@ -17,9 +17,13 @@ namespace TrigCompositeUtils
{
/// Allow all combinations
All,
/// Do not allow any repeated objects
UniqueObjects,
/// Do not allow any two objects to share an RoI
UniqueRoIs,
};
/// Helper fucntion that returns true if no objects are repeated
bool uniqueObjects(const std::vector<LinkInfo<xAOD::IParticleContainer>> &links);
/// Helper function that returns true if no objects share an initial RoI
bool uniqueRoIs(const std::vector<LinkInfo<xAOD::IParticleContainer>> &links);
......@@ -61,13 +65,13 @@ namespace TrigCompositeUtils
*/
IPartCombItr(
const std::vector<std::tuple<std::size_t, LInfoItr_t, LInfoItr_t>> &pieces,
FilterType filter = FilterType::All);
FilterType filter = FilterType::UniqueObjects);
/// Base case constructor for the variadic constructors
IPartCombItr(const std::function<bool(const VecLInfo_t &)> filter);
/// Base case constructor for the variadict constructors
IPartCombItr(FilterType filter = FilterType::All);
IPartCombItr(FilterType filter = FilterType::UniqueObjects);
template <typename... Ts>
IPartCombItr(std::size_t k, const LInfoItr_t &begin, const LInfoItr_t &end, Ts &&... args)
......@@ -130,7 +134,7 @@ namespace TrigCompositeUtils
private:
std::function<bool(const VecLInfo_t &)> m_filter;
std::vector<std::pair<KFromNItr, LInfoItr_t>> m_itrs;
std::vector<std::pair<KFromNItr, const LInfoItr_t>> m_itrs;
VecLInfo_t m_current;
}; //> end class IPartCombItr
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment