 |
ATLAS Offline Software
|
Go to the documentation of this file.
7 #include "GaudiKernel/ServiceHandle.h"
8 #include "GaudiKernel/IIncidentSvc.h"
9 #include "GaudiKernel/ThreadLocalContext.h"
26 using vecLink_t = std::vector<ElementLink<T>>;
43 const std::string&
type,
44 const std::string&
name,
45 const IInterface* pSvcLocator) :
48 declareProperty(
"ChainNames", m_chainNames,
49 "The list of trigger chains to match.");
51 "The tool to retrieve online particles from the navigation.");
52 declareProperty(
"InputElectrons",
54 "Offline electron candidates for matching.");
55 declareProperty(
"InputPhotons",
57 "Offline photon candidates for matching.");
58 declareProperty(
"InputMuons",
60 "Offline muon candidates for matching.");
61 declareProperty(
"InputTaus",
63 "Offline tau candidates for matching.");
65 "The maximum dR between an offline and an online particle to consider "
66 "a match between them.");
67 declareProperty(
"Rerun",
m_rerun =
true,
68 "Whether to match triggers in rerun mode.");
69 declareProperty(
"OutputContainerPrefix",
m_outputPrefix=
"TrigMatch_",
70 "The prefix to add to the output containers.");
72 "If set, discard any empty chain groups. Otherwise these will cause "
75 "Warn when a trigger is removed (if the configuration is dependent "
76 "on the inputs, removal is not expected).");
84 std::sort(m_chainNames.begin(), m_chainNames.end() );
85 m_chainNames.erase(std::unique(m_chainNames.begin(), m_chainNames.end() ), m_chainNames.end() );
93 return StatusCode::SUCCESS;
98 [[maybe_unused]]
static const bool firstEvent = [&](){
99 auto itr = m_chainNames.begin();
100 while (itr != m_chainNames.end() ) {
104 ATH_MSG_WARNING(
"Removing trigger " << (*itr) <<
" -- suggests a bad tool configuration (asking for triggers not in the menu)");
107 itr = m_chainNames.erase(itr);
117 std::map<xAOD::Type::ObjectType, const xAOD::IParticleContainer *> offlineContainers;
118 std::map<xAOD::Type::ObjectType, particleVec_t> offlineCandidates;
122 if (
p.second.empty() )
125 if (!handle.isValid())
128 return StatusCode::FAILURE;
130 offlineContainers[
p.first] = handle.ptr();
131 offlineCandidates.emplace(std::make_pair(
140 std::map<const xAOD::IParticle*, particleVec_t> matches;
143 for (
const std::string&
chain : m_chainNames) {
149 std::vector<particleVec_t> onlineCombinations;
153 onlineCombinations.size() <<
" combinations found for chain" <<
chain);
157 if (onlineCombinations.size() == 0)
162 std::vector<particleVec_t> offlineCombinations;
177 for (
const particleVec_t& combination : onlineCombinations) {
182 std::vector<particleRange_t> matchCandidates;
185 part, offlineCandidates, matches);
186 matchCandidates.emplace_back(possibleMatches.begin(), possibleMatches.end() );
190 auto theseOfflineCombinations =
191 TriggerMatchingUtils::getAllDistinctCombinations<const xAOD::IParticle*>(
198 "Checking matching for chain " <<
chain
199 <<
" with " << matchCandidates.size() <<
" legs");
201 for (
const particleRange_t&
range : matchCandidates)
203 <<
" offline candidates." );
205 "Matching generated " << theseOfflineCombinations.size()
206 <<
" offline combinations");
217 for (
const particleVec_t& foundCombination : offlineCombinations) {
220 static const acc_t<vecLink_t<xAOD::IParticleContainer>> dec_links(
221 "TrigMatchedObjects");
222 vecLink_t<xAOD::IParticleContainer>&
links = dec_links(*composite);
228 if (container->trackIndices())
232 extendedCtx.proxy());
234 links.push_back(makeLink<xAOD::IParticleContainer>(
part, extendedCtx.proxy()));
238 return StatusCode::SUCCESS;
243 const std::string&
chain)
const
245 auto uniqueContainer = std::make_unique<xAOD::TrigCompositeContainer>();
246 auto aux = std::make_unique<xAOD::AuxContainerBase>();
247 uniqueContainer->setStore(aux.get() );
248 container = uniqueContainer.
get();
253 ATH_CHECK( evtStore()->record(std::move(uniqueContainer),
name) );
254 ATH_CHECK( evtStore()->record(std::move(aux),
name+
"Aux.") );
255 return StatusCode::SUCCESS;
260 std::map<xAOD::Type::ObjectType, particleVec_t>& offlineParticles,
261 std::map<const xAOD::IParticle*, particleVec_t>& cache)
const
264 auto cacheItr = cache.find(
part);
265 if (cacheItr == cache.end() ) {
271 static const constAcc_t<vecLink_t<xAOD::CaloClusterContainer>> acc_calo(
"caloClusterLinks");
276 const vecLink_t<xAOD::CaloClusterContainer>&
links = acc_calo(*cand);
277 if (
links.size() == 0 || !
links.at(0).isValid() )
290 cacheItr = cache.emplace(
293 return cacheItr->second;
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Electron_v1 Electron
Definition of the current "egamma version".
virtual SG::DataProxy * proxy(const CLID &id, const std::string &key) const =0
Get proxy with given id and key.
TrigComposite_v1 TrigComposite
Declare the latest version of the class.
Helper class to provide type-safe access to aux data.
accumulate
Update flags based on parser line args.
ElementLink< T > makeLink(const SG::View *view, const SG::ReadHandle< T > &handle, size_t index)
Create EL to a collection in view.
bool insertIntoSortedVector(std::vector< T > &vec, const T &ele, PROJ proj={})
Helper function for inserting an element into a sorted vector.
const T * get(size_type n) const
Access an element, as an rvalue.
std::vector< size_t > vec
Helper class to provide constant type-safe access to aux data.
#define ATH_MSG_VERBOSE(x)
Class providing the definition of the 4-vector interface.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.
Description of a calorimeter cluster.
::StatusCode StatusCode
StatusCode definition for legacy code.
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
utility class that acts wraps a bidirectional iterator.
Class used to describe composite objects in the HLT.
virtual double pt() const =0
The transverse momentum ( ) of the particle.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
Photon_v1 Photon
Definition of the current "egamma version".
struct TBPatternUnitContext Muon
#define ATH_MSG_WARNING(x)
@ Tau
The object is a tau (jet)
Handle class for reading from StoreGate.
std::vector< std::string > getListOfTriggers() const
decltype(auto) operator()(ObjectId< CI, CM > id) const noexcept