ATLAS Offline Software
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
DerivationFramework::TriggerMatchingTool Class Referencefinal

Tool to perform trigger matching in the derivation framework. More...

#include <TriggerMatchingTool.h>

Inheritance diagram for DerivationFramework::TriggerMatchingTool:
Collaboration diagram for DerivationFramework::TriggerMatchingTool:

Public Types

using particleVec_t = std::vector< const xAOD::IParticle * >
 Helper typedefs. More...
 

Public Member Functions

 TriggerMatchingTool (const std::string &type, const std::string &name, const IInterface *pSvcLocator)
 Constructor. More...
 
virtual StatusCode initialize () override
 Initialize the tool. More...
 
virtual StatusCode addBranches () const override
 Calculate the matchings. More...
 
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & evtStore () const
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc. More...
 
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm. More...
 
virtual StatusCode sysStart () override
 Handle START transition. More...
 
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles. More...
 
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles. More...
 
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T > &t)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc="none")
 Declare a new Gaudi property. More...
 
void updateVHKA (Gaudi::Details::PropertyBase &)
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 

Static Public Member Functions

static const InterfaceID & interfaceID ()
 AlgTool interface methods. More...
 

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution More...
 
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
 
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed. More...
 

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t
 

Private Member Functions

StatusCode createOutputContainer (xAOD::TrigCompositeContainer *&container, const std::string &chain) const
 Create an output container for the named chain. More...
 
const particleVec_tgetCandidateMatchesFor (const xAOD::IParticle *part, std::map< xAOD::Type::ObjectType, particleVec_t > &offlineParticles, std::map< const xAOD::IParticle *, particleVec_t > &cache) const
 Get all offline particles that could match a given online one. More...
 
bool matchParticles (const xAOD::IParticle *lhs, const xAOD::IParticle *rhs) const
 Check if the dR between two particles is below threshold. More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyArrayType &)
 specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleType &)
 specialization for handling Gaudi::Property<SG::VarHandleBase> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &t, const SG::NotHandleType &)
 specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray> More...
 

Private Attributes

std::vector< std::string > m_chainNames ATLAS_THREAD_SAFE
 The list of chain names to match. More...
 
ToolHandle< Trig::IIParticleRetrievalToolm_trigParticleTool {"Trig::IParticleRetrievalTool/OnlineParticleTool"}
 The tool to retrieve the online candidates. More...
 
std::map< xAOD::Type::ObjectType, SG::ReadHandleKey< xAOD::IParticleContainer > > m_offlineInputs
 The input containers to use. These are keyed by xAOD object type. More...
 
float m_drThreshold
 The DR threshold to use. More...
 
bool m_rerun
 Whether to match in rerun mode or not. More...
 
std::string m_outputPrefix
 The prefix to place at the beginning of the output containers. More...
 
bool m_checkEmptyChainGroups
 If set, discard any triggers with empty chain groups (break the job otherwise). More...
 
bool m_inputDependentConfig
 If using an input-file-dependent config then we warn when triggers are removed. More...
 
ToolHandle< Trig::TrigDecisionToolm_tdt {"Trig::TrigDecisionTool/TrigDecisionTool"}
 The trig decision tool. More...
 
ToolHandle< Trig::IMatchScoringToolm_scoreTool
 The pair scoring tool. More...
 
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default) More...
 
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default) More...
 
std::vector< SG::VarHandleKeyArray * > m_vhka
 
bool m_varHandleArraysDeclared
 

Detailed Description

Tool to perform trigger matching in the derivation framework.

Trigger matching in the derivation framework has to take the reverse approach to matching in analysis code. There, the matching tool is provided with a list of analysis particles to match to a given trigger. The navigation then proceeds to search out all features that match the types of those particles. In the derivation framework however, we need to get the full list of all particles that a user could ask for in their analysis code. To do this, we ask the navigation for all the relevant xAOD objects and then use those to query the available offline objects.

Author
Jon Burr

Definition at line 38 of file TriggerMatchingTool.h.

Member Typedef Documentation

◆ particleVec_t

Helper typedefs.

Definition at line 43 of file TriggerMatchingTool.h.

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ TriggerMatchingTool()

DerivationFramework::TriggerMatchingTool::TriggerMatchingTool ( const std::string &  type,
const std::string &  name,
const IInterface *  pSvcLocator 
)

Constructor.

Definition at line 42 of file TriggerMatchingTool.cxx.

45  :
46  AthAlgTool(type, name, pSvcLocator)
47  {
48  declareInterface<IAugmentationTool>(this);
49  declareProperty("ChainNames", m_chainNames,
50  "The list of trigger chains to match.");
51  declareProperty("OnlineParticleTool", m_trigParticleTool,
52  "The tool to retrieve online particles from the navigation.");
53  declareProperty("InputElectrons",
55  "Offline electron candidates for matching.");
56  declareProperty("InputPhotons",
58  "Offline photon candidates for matching.");
59  declareProperty("InputMuons",
61  "Offline muon candidates for matching.");
62  declareProperty("InputTaus",
63  m_offlineInputs[xAOD::Type::Tau] = "TauJets",
64  "Offline tau candidates for matching.");
65  declareProperty("DRThreshold", m_drThreshold = 0.1,
66  "The maximum dR between an offline and an online particle to consider "
67  "a match between them.");
68  declareProperty("Rerun", m_rerun = true,
69  "Whether to match triggers in rerun mode.");
70  declareProperty("OutputContainerPrefix", m_outputPrefix="TrigMatch_",
71  "The prefix to add to the output containers.");
72  declareProperty("CheckEmptyChainGroups", m_checkEmptyChainGroups = true,
73  "If set, discard any empty chain groups. Otherwise these will cause "
74  "a job failure.");
75  declareProperty("InputDependentConfig", m_inputDependentConfig=false,
76  "Warn when a trigger is removed (if the configuration is dependent "
77  "on the inputs, removal is not expected).");
78  }

Member Function Documentation

◆ addBranches()

StatusCode DerivationFramework::TriggerMatchingTool::addBranches ( ) const
overridevirtual

Calculate the matchings.

Implements DerivationFramework::IAugmentationTool.

Definition at line 97 of file TriggerMatchingTool.cxx.

98  {
99  [[maybe_unused]] static const bool firstEvent = [&](){
100  auto itr = m_chainNames.begin();
101  while (itr != m_chainNames.end() ) {
102  const Trig::ChainGroup* cg = m_tdt->getChainGroup(*itr);
103  if (cg->getListOfTriggers().size() == 0){
105  ATH_MSG_WARNING("Removing trigger " << (*itr) << " -- suggests a bad tool configuration (asking for triggers not in the menu)");
106  // We are now modifying the mutable m_chainNames but since it is done
107  // within this static initialization this is thread-safe:
108  itr = m_chainNames.erase(itr);
109  } else
110  ++itr;
111  }
112  return false;
113  }();
114 
115  const EventContext &ctx = Gaudi::Hive::currentContext();
117 
118  // Now, get all the possible offline candidates
119  std::map<xAOD::Type::ObjectType, const xAOD::IParticleContainer *> offlineContainers;
120  std::map<xAOD::Type::ObjectType, particleVec_t> offlineCandidates;
121  for (const auto& p : m_offlineInputs) {
122  // Skip any that may have been disabled by providing an empty string to
123  // the corresponding property
124  if (p.second.empty() )
125  continue;
126  auto handle = SG::makeHandle(p.second, ctx);
127  if (!handle.isValid())
128  {
129  ATH_MSG_ERROR("Failed to retrieve " << p.second);
130  return StatusCode::FAILURE;
131  }
132  offlineContainers[p.first] = handle.ptr();
133  offlineCandidates.emplace(std::make_pair(
134  p.first,
135  particleVec_t(handle->begin(), handle->end() )
136  ) );
137  }
138 
139  // Store possible matches from online to offline particles here
140  // We do this as multiple chains may use the same online particles so we can
141  // reuse this information.
142  std::map<const xAOD::IParticle*, particleVec_t> matches;
143 
144  // Iterate through the chains to get the matchings
145  for (const std::string& chain : m_chainNames) {
146  // Create the output
147  xAOD::TrigCompositeContainer* container(nullptr);
148  ATH_CHECK( createOutputContainer(container, chain) );
149 
150  // Get the list of online combinations
151  std::vector<particleVec_t> onlineCombinations;
152  ATH_CHECK( m_trigParticleTool->retrieveParticles(onlineCombinations, chain, m_rerun) );
153 
155  onlineCombinations.size() << " combinations found for chain" << chain);
156 
157  // If no combinations were found (because the trigger was not passed) then
158  // we can skip this trigger
159  if (onlineCombinations.size() == 0)
160  continue;
161 
162  using particleRange_t = TriggerMatchingUtils::RangedItr<typename particleVec_t::const_iterator>;
163  // Now build up the list of offline combinations;
164  std::vector<particleVec_t> offlineCombinations;
165  for (const particleVec_t& combination : onlineCombinations) {
166  // Here we store the possible candidates for the matching. We use the
167  // range type as a lightweight method to carry around a view of a vector
168  // without copying it (the RangedItr is essentially a combination of 3
169  // iterators).
170  std::vector<particleRange_t> matchCandidates;
171  for (const xAOD::IParticle* part : combination) {
172  const particleVec_t& possibleMatches = getCandidateMatchesFor(
173  part, offlineCandidates, matches);
174  matchCandidates.emplace_back(possibleMatches.begin(), possibleMatches.end() );
175  } //> end loop over particles
176  // Get all possible combinations of offline objects that could match to
177  // this particular online combination.
178  auto theseOfflineCombinations =
179  TriggerMatchingUtils::getAllDistinctCombinations<const xAOD::IParticle*>(
180  matchCandidates);
181  if (msgLvl(MSG::VERBOSE) ) {
182  // Spit out some verbose information
184  "Checking matching for chain " << chain
185  << " with " << matchCandidates.size() << " legs");
186  std::size_t idx = 0;
187  for (const particleRange_t& range : matchCandidates)
188  ATH_MSG_VERBOSE( "Leg #" << idx++ << " has " << range.size()
189  << " offline candidates." );
191  "Matching generated " << theseOfflineCombinations.size()
192  << " offline combinations");
193  }
194  // Now push them back into the output. Use a specialised function for
195  // inserting into a sorted vector that ensures that we only output
196  // unique combinations
197  for (const particleVec_t& vec : theseOfflineCombinations)
199  } //> end loop over combinations
200 
201 
202  // Decorate the found combinations onto trigger composites.
203  for (const particleVec_t& foundCombination : offlineCombinations) {
204  xAOD::TrigComposite* composite = new xAOD::TrigComposite();
205  container->push_back(composite);
206  static const acc_t<vecLink_t<xAOD::IParticleContainer>> dec_links(
207  "TrigMatchedObjects");
208  vecLink_t<xAOD::IParticleContainer>& links = dec_links(*composite);
209  for (const xAOD::IParticle* part : foundCombination) {
210  const xAOD::IParticleContainer *container = offlineContainers.at(part->type());
211  // If we have an owning container then things are relatively simple:
212  // we can just construct the element link from its SG key and the
213  // index. Otherwise we have to locate the correct proxy from the element
214  if (container->trackIndices())
215  links.emplace_back(
216  m_offlineInputs.at(part->type()).key(),
217  part->index(),
218  extendedCtx.proxy());
219  else
220  links.push_back(makeLink<xAOD::IParticleContainer>(part, extendedCtx.proxy()));
221  }
222  } //> end loop over the found combinations
223  } //> end loop over chains
224  return StatusCode::SUCCESS;
225  }

◆ createOutputContainer()

StatusCode DerivationFramework::TriggerMatchingTool::createOutputContainer ( xAOD::TrigCompositeContainer *&  container,
const std::string &  chain 
) const
private

Create an output container for the named chain.

Parameters
[out]containerA pointer to the created container
chainThe name of the chain to create the container for The container will be recorded in the StoreGate using the name of the chain as a key.

Definition at line 227 of file TriggerMatchingTool.cxx.

230  {
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();
235  std::string name = m_outputPrefix+chain;
236  // We have to replace '.' characters with '_' characters so that these are
237  // valid container names...
238  std::replace(name.begin(), name.end(), '.', '_');
239  ATH_CHECK( evtStore()->record(std::move(uniqueContainer), name) );
240  ATH_CHECK( evtStore()->record(std::move(aux), name+"Aux.") );
241  return StatusCode::SUCCESS;
242  }

◆ declareGaudiProperty() [1/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyArrayType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKeyArray>

Definition at line 170 of file AthCommonDataStore.h.

172  {
173  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
174  hndl.value(),
175  hndl.documentation());
176 
177  }

◆ declareGaudiProperty() [2/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158  {
159  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
160  hndl.value(),
161  hndl.documentation());
162 
163  }

◆ declareGaudiProperty() [3/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleBase>

Definition at line 184 of file AthCommonDataStore.h.

186  {
187  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
188  hndl.value(),
189  hndl.documentation());
190  }

◆ declareGaudiProperty() [4/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  t,
const SG::NotHandleType  
)
inlineprivateinherited

specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray>

Definition at line 199 of file AthCommonDataStore.h.

200  {
201  return PBASE::declareProperty(t);
202  }

◆ declareProperty() [1/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleBase hndl,
const std::string &  doc,
const SG::VarHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleBase. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 245 of file AthCommonDataStore.h.

249  {
250  this->declare(hndl.vhKey());
251  hndl.vhKey().setOwner(this);
252 
253  return PBASE::declareProperty(name,hndl,doc);
254  }

◆ declareProperty() [2/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKey hndl,
const std::string &  doc,
const SG::VarHandleKeyType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleKey. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 221 of file AthCommonDataStore.h.

225  {
226  this->declare(hndl);
227  hndl.setOwner(this);
228 
229  return PBASE::declareProperty(name,hndl,doc);
230  }

◆ declareProperty() [3/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKeyArray hndArr,
const std::string &  doc,
const SG::VarHandleKeyArrayType  
)
inlineinherited

Definition at line 259 of file AthCommonDataStore.h.

263  {
264 
265  // std::ostringstream ost;
266  // ost << Algorithm::name() << " VHKA declareProp: " << name
267  // << " size: " << hndArr.keys().size()
268  // << " mode: " << hndArr.mode()
269  // << " vhka size: " << m_vhka.size()
270  // << "\n";
271  // debug() << ost.str() << endmsg;
272 
273  hndArr.setOwner(this);
274  m_vhka.push_back(&hndArr);
275 
276  Gaudi::Details::PropertyBase* p = PBASE::declareProperty(name, hndArr, doc);
277  if (p != 0) {
278  p->declareUpdateHandler(&AthCommonDataStore<PBASE>::updateVHKA, this);
279  } else {
280  ATH_MSG_ERROR("unable to call declareProperty on VarHandleKeyArray "
281  << name);
282  }
283 
284  return p;
285 
286  }

◆ declareProperty() [4/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc,
const SG::NotHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This is the generic version, for types that do not derive from SG::VarHandleKey. It just forwards to the base class version of declareProperty.

Definition at line 333 of file AthCommonDataStore.h.

337  {
338  return PBASE::declareProperty(name, property, doc);
339  }

◆ declareProperty() [5/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc = "none" 
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This dispatches to either the generic declareProperty or the one for VarHandle/Key/KeyArray.

Definition at line 352 of file AthCommonDataStore.h.

355  {
356  typedef typename SG::HandleClassifier<T>::type htype;
357  return declareProperty (name, property, doc, htype());
358  }

◆ declareProperty() [6/6]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T > &  t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145  {
146  typedef typename SG::HandleClassifier<T>::type htype;
148  }

◆ detStore()

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

95 { return m_detStore; }

◆ evtStore() [1/2]

ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

85 { return m_evtStore; }

◆ evtStore() [2/2]

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( ) const
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 90 of file AthCommonDataStore.h.

90 { return m_evtStore; }

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase &  ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ getCandidateMatchesFor()

const TriggerMatchingTool::particleVec_t & DerivationFramework::TriggerMatchingTool::getCandidateMatchesFor ( const xAOD::IParticle part,
std::map< xAOD::Type::ObjectType, particleVec_t > &  offlineParticles,
std::map< const xAOD::IParticle *, particleVec_t > &  cache 
) const
private

Get all offline particles that could match a given online one.

Parameters
partThe online particle to match against.
offlineParticlesThe offline particles, key by xAOD type.
cacheStore past matches here to speed up future look ups.

Definition at line 244 of file TriggerMatchingTool.cxx.

248  {
249  // Build up all the possible matches between online and offline particles
250  auto cacheItr = cache.find(part);
251  if (cacheItr == cache.end() ) {
252  xAOD::Type::ObjectType type = part->type();
254  if (type == xAOD::Type::CaloCluster) {
255  // If it's a calo cluster then we need to get the cluster from the
256  // egamma types.
257  static const constAcc_t<vecLink_t<xAOD::CaloClusterContainer>> acc_calo("caloClusterLinks");
258  for (xAOD::Type::ObjectType egType : {
260  {
261  for (const xAOD::IParticle* cand : offlineParticles[egType]) {
262  const vecLink_t<xAOD::CaloClusterContainer>& links = acc_calo(*cand);
263  if (links.size() == 0 || !links.at(0).isValid() )
264  continue;
265  const xAOD::CaloCluster* clus = *links.at(0);
266  if (matchParticles(part, clus) )
267  candidates.push_back(cand);
268  }
269  }
270  }
271  else {
272  for (const xAOD::IParticle* cand : offlineParticles[type])
273  if (matchParticles(part, cand) )
274  candidates.push_back(cand);
275  }
276  cacheItr = cache.emplace(
277  std::make_pair(part, std::move(candidates) ) ).first;
278  }
279  return cacheItr->second;
280  }

◆ initialize()

StatusCode DerivationFramework::TriggerMatchingTool::initialize ( )
overridevirtual

Initialize the tool.

Definition at line 80 of file TriggerMatchingTool.cxx.

81  {
82  ATH_MSG_INFO( "Initializing " << name() );
83 
84  // Remove any duplicates from the list of chain names
85  std::sort(m_chainNames.begin(), m_chainNames.end() );
86  m_chainNames.erase(std::unique(m_chainNames.begin(), m_chainNames.end() ), m_chainNames.end() );
87 
88  ATH_CHECK( m_trigParticleTool.retrieve() );
89  ATH_CHECK( m_scoreTool.retrieve() );
90  for (auto &p : m_offlineInputs)
91  {
92  ATH_CHECK(p.second.initialize(SG::AllowEmpty));
93  }
94  return StatusCode::SUCCESS;
95  }

◆ inputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

static const InterfaceID& DerivationFramework::IAugmentationTool::interfaceID ( )
inlinestaticinherited

AlgTool interface methods.

Definition at line 31 of file IAugmentationTool.h.

31 { return IID_IAugmentationTool; }

◆ matchParticles()

bool DerivationFramework::TriggerMatchingTool::matchParticles ( const xAOD::IParticle lhs,
const xAOD::IParticle rhs 
) const
private

Check if the dR between two particles is below threshold.

Definition at line 282 of file TriggerMatchingTool.cxx.

285  {
286  return m_scoreTool->score(*lhs, *rhs) < m_drThreshold;
287  }

◆ msg() [1/2]

MsgStream& AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24  {
25  return this->msgStream();
26  }

◆ msg() [2/2]

MsgStream& AthCommonMsg< AlgTool >::msg ( const MSG::Level  lvl) const
inlineinherited

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30  {
31  return this->msgLevel(lvl);
32  }

◆ outputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t<std::is_void_v<std::result_of_t<decltype(&T::renounce)(T)> > && !std::is_base_of_v<SG::VarHandleKeyArray, T> && std::is_base_of_v<Gaudi::DataHandle, T>, void> AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T &  h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381  {
382  h.renounce();
383  PBASE::renounce (h);
384  }

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364  {
365  handlesArray.renounce();
366  }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in DerivationFramework::CfAthAlgTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and asg::AsgMetadataTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase &  )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308  {
309  // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310  // << " size: " << m_vhka.size() << endmsg;
311  for (auto &a : m_vhka) {
312  std::vector<SG::VarHandleKey*> keys = a->keys();
313  for (auto k : keys) {
314  k->setOwner(this);
315  }
316  }
317  }

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::vector<std::string> m_chainNames DerivationFramework::TriggerMatchingTool::ATLAS_THREAD_SAFE
mutableprivate

The list of chain names to match.

Definition at line 59 of file TriggerMatchingTool.h.

◆ m_checkEmptyChainGroups

bool DerivationFramework::TriggerMatchingTool::m_checkEmptyChainGroups
private

If set, discard any triggers with empty chain groups (break the job otherwise).

Definition at line 84 of file TriggerMatchingTool.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_drThreshold

float DerivationFramework::TriggerMatchingTool::m_drThreshold
private

The DR threshold to use.

Definition at line 74 of file TriggerMatchingTool.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_inputDependentConfig

bool DerivationFramework::TriggerMatchingTool::m_inputDependentConfig
private

If using an input-file-dependent config then we warn when triggers are removed.

Definition at line 88 of file TriggerMatchingTool.h.

◆ m_offlineInputs

std::map<xAOD::Type::ObjectType, SG::ReadHandleKey<xAOD::IParticleContainer> > DerivationFramework::TriggerMatchingTool::m_offlineInputs
private

The input containers to use. These are keyed by xAOD object type.

Definition at line 71 of file TriggerMatchingTool.h.

◆ m_outputPrefix

std::string DerivationFramework::TriggerMatchingTool::m_outputPrefix
private

The prefix to place at the beginning of the output containers.

Definition at line 80 of file TriggerMatchingTool.h.

◆ m_rerun

bool DerivationFramework::TriggerMatchingTool::m_rerun
private

Whether to match in rerun mode or not.

Definition at line 77 of file TriggerMatchingTool.h.

◆ m_scoreTool

ToolHandle<Trig::IMatchScoringTool> DerivationFramework::TriggerMatchingTool::m_scoreTool
private
Initial value:
{
this, "ScoringTool", "Trig::DRScoringTool", "The pair scoring tool"}

The pair scoring tool.

Definition at line 94 of file TriggerMatchingTool.h.

◆ m_tdt

ToolHandle<Trig::TrigDecisionTool> DerivationFramework::TriggerMatchingTool::m_tdt {"Trig::TrigDecisionTool/TrigDecisionTool"}
private

The trig decision tool.

Definition at line 91 of file TriggerMatchingTool.h.

◆ m_trigParticleTool

ToolHandle<Trig::IIParticleRetrievalTool> DerivationFramework::TriggerMatchingTool::m_trigParticleTool {"Trig::IParticleRetrievalTool/OnlineParticleTool"}
private

The tool to retrieve the online candidates.

Definition at line 68 of file TriggerMatchingTool.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files:
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
DerivationFramework::TriggerMatchingTool::m_drThreshold
float m_drThreshold
The DR threshold to use.
Definition: TriggerMatchingTool.h:74
DerivationFramework::TriggerMatchingTool::matchParticles
bool matchParticles(const xAOD::IParticle *lhs, const xAOD::IParticle *rhs) const
Check if the dR between two particles is below threshold.
Definition: TriggerMatchingTool.cxx:282
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
runLayerRecalibration.chain
chain
Definition: runLayerRecalibration.py:175
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
DerivationFramework::TriggerMatchingTool::m_outputPrefix
std::string m_outputPrefix
The prefix to place at the beginning of the output containers.
Definition: TriggerMatchingTool.h:80
xAOD::TrigComposite
TrigComposite_v1 TrigComposite
Declare the latest version of the class.
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:16
ObjectType
ObjectType
Definition: BaseObject.h:11
drawFromPickle.candidates
candidates
Definition: drawFromPickle.py:271
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: AthCommonDataStore.h:390
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
std::vector< SG::VarHandleKeyArray * > m_vhka
Definition: AthCommonDataStore.h:398
DataVector::get
const T * get(size_type n) const
Access an element, as an rvalue.
AthCommonMsg< AlgTool >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
DerivationFramework::TriggerMatchingTool::m_scoreTool
ToolHandle< Trig::IMatchScoringTool > m_scoreTool
The pair scoring tool.
Definition: TriggerMatchingTool.h:94
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:40
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
DerivationFramework::TriggerMatchingUtils::insertIntoSortedVector
bool insertIntoSortedVector(std::vector< T > &vec, const T &ele)
Helper function for inserting an element into a sorted vector.
DerivationFramework::TriggerMatchingTool::m_checkEmptyChainGroups
bool m_checkEmptyChainGroups
If set, discard any triggers with empty chain groups (break the job otherwise).
Definition: TriggerMatchingTool.h:84
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:269
Atlas::getExtendedEventContext
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.
Definition: ExtendedEventContext.cxx:32
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
AthCommonDataStore
Definition: AthCommonDataStore.h:52
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
DerivationFramework::TriggerMatchingTool::m_trigParticleTool
ToolHandle< Trig::IIParticleRetrievalTool > m_trigParticleTool
The tool to retrieve the online candidates.
Definition: TriggerMatchingTool.h:68
Atlas::ExtendedEventContext
Definition: ExtendedEventContext.h:23
DerivationFramework::TriggerMatchingTool::particleVec_t
std::vector< const xAOD::IParticle * > particleVec_t
Helper typedefs.
Definition: TriggerMatchingTool.h:43
DerivationFramework::TriggerMatchingTool::m_rerun
bool m_rerun
Whether to match in rerun mode or not.
Definition: TriggerMatchingTool.h:77
DMTest::links
links
Definition: CLinks_v1.cxx:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
DerivationFramework::TriggerMatchingTool::m_tdt
ToolHandle< Trig::TrigDecisionTool > m_tdt
The trig decision tool.
Definition: TriggerMatchingTool.h:91
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
xAOD::TrigComposite_v1
Class used to describe composite objects in the HLT.
Definition: TrigComposite_v1.h:52
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
AthAlgTool::AthAlgTool
AthAlgTool()
Default constructor:
SG::VarHandleKeyArray::renounce
virtual void renounce()=0
SG::HandleClassifier::type
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
Definition: HandleClassifier.h:54
Trig::ChainGroup
Definition: Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/ChainGroup.h:51
DerivationFramework::TriggerMatchingTool::getCandidateMatchesFor
const particleVec_t & getCandidateMatchesFor(const xAOD::IParticle *part, std::map< xAOD::Type::ObjectType, particleVec_t > &offlineParticles, std::map< const xAOD::IParticle *, particleVec_t > &cache) const
Get all offline particles that could match a given online one.
Definition: TriggerMatchingTool.cxx:244
DerivationFramework::TriggerMatchingTool::m_offlineInputs
std::map< xAOD::Type::ObjectType, SG::ReadHandleKey< xAOD::IParticleContainer > > m_offlineInputs
The input containers to use. These are keyed by xAOD object type.
Definition: TriggerMatchingTool.h:71
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
DerivationFramework::TriggerMatchingTool::m_inputDependentConfig
bool m_inputDependentConfig
If using an input-file-dependent config then we warn when triggers are removed.
Definition: TriggerMatchingTool.h:88
xAOD::Photon
Photon_v1 Photon
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Photon.h:17
Muon
struct TBPatternUnitContext Muon
a
TList * a
Definition: liststreamerinfos.cxx:10
h
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:616
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
xAODType::Tau
@ Tau
The object is a tau (jet)
Definition: ObjectType.h:49
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
Trig::ChainGroup::getListOfTriggers
std::vector< std::string > getListOfTriggers() const
Definition: Trigger/TrigAnalysis/TrigDecisionTool/Root/ChainGroup.cxx:467
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
fitman.k
k
Definition: fitman.py:528
DerivationFramework::TriggerMatchingTool::createOutputContainer
StatusCode createOutputContainer(xAOD::TrigCompositeContainer *&container, const std::string &chain) const
Create an output container for the named chain.
Definition: TriggerMatchingTool.cxx:227