|
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 declareInterface<IAugmentationTool>(
this);
50 "The list of trigger chains to match.");
52 "The tool to retrieve online particles from the navigation.");
55 "Offline electron candidates for matching.");
58 "Offline photon candidates for matching.");
61 "Offline muon candidates for matching.");
64 "Offline tau candidates for matching.");
66 "The maximum dR between an offline and an online particle to consider "
67 "a match between them.");
69 "Whether to match triggers in rerun mode.");
71 "The prefix to add to the output containers.");
73 "If set, discard any empty chain groups. Otherwise these will cause "
76 "Warn when a trigger is removed (if the configuration is dependent "
77 "on the inputs, removal is not expected).");
85 std::sort(m_chainNames.begin(), m_chainNames.end() );
86 m_chainNames.erase(std::unique(m_chainNames.begin(), m_chainNames.end() ), m_chainNames.end() );
94 return StatusCode::SUCCESS;
99 [[maybe_unused]]
static const bool firstEvent = [&](){
100 auto itr = m_chainNames.begin();
101 while (itr != m_chainNames.end() ) {
105 ATH_MSG_WARNING(
"Removing trigger " << (*itr) <<
" -- suggests a bad tool configuration (asking for triggers not in the menu)");
108 itr = m_chainNames.erase(itr);
115 const EventContext &ctx = Gaudi::Hive::currentContext();
119 std::map<xAOD::Type::ObjectType, const xAOD::IParticleContainer *> offlineContainers;
120 std::map<xAOD::Type::ObjectType, particleVec_t> offlineCandidates;
124 if (
p.second.empty() )
127 if (!handle.isValid())
130 return StatusCode::FAILURE;
132 offlineContainers[
p.first] = handle.ptr();
133 offlineCandidates.emplace(std::make_pair(
142 std::map<const xAOD::IParticle*, particleVec_t> matches;
145 for (
const std::string&
chain : m_chainNames) {
151 std::vector<particleVec_t> onlineCombinations;
155 onlineCombinations.size() <<
" combinations found for chain" <<
chain);
159 if (onlineCombinations.size() == 0)
164 std::vector<particleVec_t> offlineCombinations;
165 for (
const particleVec_t& combination : onlineCombinations) {
170 std::vector<particleRange_t> matchCandidates;
173 part, offlineCandidates, matches);
174 matchCandidates.emplace_back(possibleMatches.begin(), possibleMatches.end() );
178 auto theseOfflineCombinations =
179 TriggerMatchingUtils::getAllDistinctCombinations<const xAOD::IParticle*>(
184 "Checking matching for chain " <<
chain
185 <<
" with " << matchCandidates.size() <<
" legs");
187 for (
const particleRange_t&
range : matchCandidates)
189 <<
" offline candidates." );
191 "Matching generated " << theseOfflineCombinations.size()
192 <<
" offline combinations");
203 for (
const particleVec_t& foundCombination : offlineCombinations) {
206 static const acc_t<vecLink_t<xAOD::IParticleContainer>> dec_links(
207 "TrigMatchedObjects");
208 vecLink_t<xAOD::IParticleContainer>&
links = dec_links(*composite);
214 if (container->trackIndices())
218 extendedCtx.proxy());
220 links.push_back(makeLink<xAOD::IParticleContainer>(
part, extendedCtx.proxy()));
224 return StatusCode::SUCCESS;
229 const std::string&
chain)
const
231 auto uniqueContainer = std::make_unique<xAOD::TrigCompositeContainer>();
232 auto aux = std::make_unique<xAOD::AuxContainerBase>();
233 uniqueContainer->setStore(aux.get() );
234 container = uniqueContainer.
get();
241 return StatusCode::SUCCESS;
246 std::map<xAOD::Type::ObjectType, particleVec_t>& offlineParticles,
247 std::map<const xAOD::IParticle*, particleVec_t>& cache)
const
250 auto cacheItr = cache.find(
part);
251 if (cacheItr == cache.end() ) {
257 static const constAcc_t<vecLink_t<xAOD::CaloClusterContainer>> acc_calo(
"caloClusterLinks");
262 const vecLink_t<xAOD::CaloClusterContainer>&
links = acc_calo(*cand);
263 if (
links.size() == 0 || !
links.at(0).isValid() )
276 cacheItr = cache.emplace(
279 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.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
ElementLink< T > makeLink(const SG::View *view, const SG::ReadHandle< T > &handle, size_t index)
Create EL to a collection in view.
const T * get(size_type n) const
Access an element, as an rvalue.
bool msgLvl(const MSG::Level lvl) const
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.
bool insertIntoSortedVector(std::vector< T > &vec, const T &ele)
Helper function for inserting an element into a sorted vector.
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.
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Description of a calorimeter cluster.
::StatusCode StatusCode
StatusCode definition for legacy code.
utility class that acts wraps a bidirectional iterator.
Class used to describe composite objects in the HLT.
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