 |
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);
114 const EventContext &ctx = Gaudi::Hive::currentContext();
118 std::map<xAOD::Type::ObjectType, const xAOD::IParticleContainer *> offlineContainers;
119 std::map<xAOD::Type::ObjectType, particleVec_t> offlineCandidates;
123 if (
p.second.empty() )
126 if (!handle.isValid())
129 return StatusCode::FAILURE;
131 offlineContainers[
p.first] = handle.ptr();
132 offlineCandidates.emplace(std::make_pair(
141 std::map<const xAOD::IParticle*, particleVec_t> matches;
144 for (
const std::string&
chain : m_chainNames) {
150 std::vector<particleVec_t> onlineCombinations;
154 onlineCombinations.size() <<
" combinations found for chain" <<
chain);
158 if (onlineCombinations.size() == 0)
163 std::vector<particleVec_t> offlineCombinations;
178 for (
const particleVec_t& combination : onlineCombinations) {
183 std::vector<particleRange_t> matchCandidates;
186 part, offlineCandidates, matches);
187 matchCandidates.emplace_back(possibleMatches.begin(), possibleMatches.end() );
191 auto theseOfflineCombinations =
192 TriggerMatchingUtils::getAllDistinctCombinations<const xAOD::IParticle*>(
199 "Checking matching for chain " <<
chain
200 <<
" with " << matchCandidates.size() <<
" legs");
202 for (
const particleRange_t&
range : matchCandidates)
204 <<
" offline candidates." );
206 "Matching generated " << theseOfflineCombinations.size()
207 <<
" offline combinations");
218 for (
const particleVec_t& foundCombination : offlineCombinations) {
221 static const acc_t<vecLink_t<xAOD::IParticleContainer>> dec_links(
222 "TrigMatchedObjects");
223 vecLink_t<xAOD::IParticleContainer>&
links = dec_links(*composite);
229 if (container->trackIndices())
233 extendedCtx.proxy());
235 links.push_back(makeLink<xAOD::IParticleContainer>(
part, extendedCtx.proxy()));
239 return StatusCode::SUCCESS;
244 const std::string&
chain)
const
246 auto uniqueContainer = std::make_unique<xAOD::TrigCompositeContainer>();
247 auto aux = std::make_unique<xAOD::AuxContainerBase>();
248 uniqueContainer->setStore(aux.get() );
249 container = uniqueContainer.
get();
254 ATH_CHECK( evtStore()->record(std::move(uniqueContainer),
name) );
255 ATH_CHECK( evtStore()->record(std::move(aux),
name+
"Aux.") );
256 return StatusCode::SUCCESS;
261 std::map<xAOD::Type::ObjectType, particleVec_t>& offlineParticles,
262 std::map<const xAOD::IParticle*, particleVec_t>& cache)
const
265 auto cacheItr = cache.find(
part);
266 if (cacheItr == cache.end() ) {
272 static const constAcc_t<vecLink_t<xAOD::CaloClusterContainer>> acc_calo(
"caloClusterLinks");
277 const vecLink_t<xAOD::CaloClusterContainer>&
links = acc_calo(*cand);
278 if (
links.size() == 0 || !
links.at(0).isValid() )
291 cacheItr = cache.emplace(
294 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.
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
accumulate
Update flags based on parser line args.
#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