ATLAS Offline Software
Classes | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
InDet::InDetHardScatterSelectionTool Class Reference

Implementation of the hardscatter selection tool. More...

#include <InDetHardScatterSelectionTool.h>

Inheritance diagram for InDet::InDetHardScatterSelectionTool:
Collaboration diagram for InDet::InDetHardScatterSelectionTool:

Classes

class  Sum
 

Public Types

Running mode(s) for hardscatter determination
enum  Mode { SumPt2 = 0, SumPt = 1, SumPtw = 2 }
 

Public Member Functions

virtual void print () const
 Print the state of the tool. 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
 
Constructor(s)/destructor(s)
 InDetHardScatterSelectionTool (const std::string &name)
 Constructor. More...
 
 ~InDetHardScatterSelectionTool ()
 Destructor. More...
 
Function(s) implementing the asg::IAsgTool interface
virtual StatusCode initialize () override
 Function initialising the tool. More...
 
virtual StatusCode finalize () override
 Function finalizing the tool. More...
 
Function(s) implementing the IInDetHardScatterSelectionTool interface
const xAOD::VertexgetHardScatter (const xAOD::VertexContainer *vtxCont) const override
 Function for returning the hardscatter vertex. More...
 
const xAOD::VertexgetHardScatter () const override
 
ElementLink< xAOD::VertexContainergetHardScatterLink (const xAOD::VertexContainer *vtxCont) const override
 Function for returning the hardscatter vertex link. More...
 
ElementLink< xAOD::VertexContainergetHardScatterLink () const override
 

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

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

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
 
Truly private internal data members
std::unique_ptr< Summ_sum
 A helper class which either sums pt2 or pt or ptw. More...
 
bool m_doTrkSelection = false
 A flag which will be true if an InDetTrackSelectionTool was provided. More...
 
SG::ReadHandleKey< xAOD::EventInfom_evtInfoKey {this, "EventInfo", "EventInfo", "EventInfo key"}
 xAOD::EventInfo ReadHandleKey More...
 
SG::ReadHandleKey< xAOD::VertexContainerm_vtxContKey {this, "VertexContainer", "PrimaryVertices", "Name of the primary vertex container"}
 
SG::ReadHandleKey< xAOD::JetContainerm_jetContKey { this, "JetContainer", "AntiKt4EMTopoJets", "Name of the jet container" }
 
BooleanProperty m_redoHardScatter { this, "RedoHardScatter", false, "If true, redo the hardscatter selection using sumpt2 or sumpt or sumptw"}
 
IntegerProperty m_mode { this, "SelectionMode", InDet::InDetHardScatterSelectionTool::Mode::SumPt2, "Mode for selecting the hardscatter: sumpt2[0] or sumpt[1] or sumptw[2]"}
 
ToolHandle< InDet::IInDetTrackSelectionToolm_trkSelectTool {this, "TrackSelectionTool", "InDet::InDetTrackSelectionTool/TrackSelectionTool", "Track selection tool to use"}
 
BooleanProperty m_returnDeco { this, "ReturnDeco", false, "If true, return the hardscatter as the vertex decorated with some boolean"}
 
StringProperty m_hardScatterDeco {this, "HardScatterLinkDeco", "hardScatterVertexLink", "The decoration name of the ElementLink to the hardscatter vertex (applied to xAOD::EventInfo)"}
 
FloatProperty m_jetMinPt {this, "jetMinPt", 15000.0, "minimum jet pt"}
 
FloatProperty m_jetTrkMaxDr {this, "jetTrkMaxDr", 0.8, "max dR between jet & Trk"}
 
FloatProperty m_trkMaxPt {this, "trkMaxPt", 10045000, "max track pt"}
 
SG::ReadDecorHandleKey< xAOD::EventInfom_hardScatterDecoKey {this, "VertexScatterKey", "" , "Overwrriten in the configuration step by the <HardScatterLinkDeco> property"}
 The decoration name of the ElementLink to the hardscatter vertex (applied to xAOD::EventInfo) More...
 

Detailed Description

Implementation of the hardscatter selection tool.

Definition at line 45 of file InDetHardScatterSelectionTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Member Enumeration Documentation

◆ Mode

Enumerator
SumPt2 
SumPt 
SumPtw 

Definition at line 60 of file InDetHardScatterSelectionTool.h.

60  {
61  SumPt2 = 0,
62  SumPt = 1,
63  SumPtw = 2
64  };

Constructor & Destructor Documentation

◆ InDetHardScatterSelectionTool()

InDet::InDetHardScatterSelectionTool::InDetHardScatterSelectionTool ( const std::string &  name)

Constructor.

Definition at line 45 of file InDetHardScatterSelectionTool.cxx.

45  :
47 {}

◆ ~InDetHardScatterSelectionTool()

InDet::InDetHardScatterSelectionTool::~InDetHardScatterSelectionTool ( )
default

Destructor.

Member Function Documentation

◆ 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

◆ finalize()

StatusCode InDet::InDetHardScatterSelectionTool::finalize ( )
overridevirtual

Function finalizing the tool.

Definition at line 126 of file InDetHardScatterSelectionTool.cxx.

127 {
128  ATH_MSG_DEBUG("Finalizing " << name() << "...");
129 
130  // Release our tool
131  if (m_redoHardScatter && !m_trkSelectTool.empty()) ATH_CHECK(m_trkSelectTool.release());
132 
133  return StatusCode::SUCCESS;
134 }

◆ getHardScatter() [1/2]

const xAOD::Vertex * InDet::InDetHardScatterSelectionTool::getHardScatter ( ) const
overridevirtual

Implements InDet::IInDetHardScatterSelectionTool.

Definition at line 225 of file InDetHardScatterSelectionTool.cxx.

226 {
227  const EventContext& ctx = Gaudi::Hive::currentContext();
229  if (!vtxCont.isValid()) {
230  ATH_MSG_ERROR("Could not open primary vertex container, returning nullptr!");
231  return nullptr;
232  }
233  return getHardScatter(vtxCont.get());
234 }

◆ getHardScatter() [2/2]

const xAOD::Vertex * InDet::InDetHardScatterSelectionTool::getHardScatter ( const xAOD::VertexContainer vtxCont) const
overridevirtual

Function for returning the hardscatter vertex.

Implements InDet::IInDetHardScatterSelectionTool.

Definition at line 136 of file InDetHardScatterSelectionTool.cxx.

137 {
138  ATH_MSG_DEBUG("In getHardScatter(...) for " << name() << "...");
139 
140  const EventContext& ctx = Gaudi::Hive::currentContext();
141 
142  // If we are simply returning a decoration on the EventInfo:
143  if (m_returnDeco) {
145  if (!evtInfo.isValid()) {
146  ATH_MSG_ERROR("Could not open event info, returning nullptr!");
147  return nullptr;
148  }
150  const ElementLink<xAOD::VertexContainer>& vtxLink = hardScatterDeco(*evtInfo);
151  if (!vtxLink.isValid()) {
152  ATH_MSG_ERROR("Hardscatter vertex link is not valid, returning nullptr!");
153  return nullptr;
154  }
155  return *vtxLink;
156  }
157  //::get the jet container if the mode of HS selection is sumptw
158  const xAOD::JetContainer* jetCont{nullptr};
159  if ( m_mode == InDet::InDetHardScatterSelectionTool::Mode::SumPtw ){
160  //::First get the jet containers
162  if (!jetContHandle.isValid()){
163  ATH_MSG_ERROR ("HardScatterSelectionTool configured to use jet collection "<<m_jetContKey.key()<<", but collection is not found!");
164  }
165  jetCont = jetContHandle.cptr();
166  }
167 
168  float maxsum = -999.0;
169  const xAOD::Vertex* hardscatter = nullptr;
170  for (const auto *const vtx : *vtxCont) {
171  float sum = 0.;
172  // If we are redoing the hardscatter determination:
173  if (m_redoHardScatter) {
174  if ( m_mode == InDet::InDetHardScatterSelectionTool::Mode::SumPtw ){
175  for (const auto& trkLink : vtx->trackParticleLinks()) {
176  if (!trkLink.isValid()) continue;
177  if (m_doTrkSelection && !static_cast<bool>(m_trkSelectTool->accept(**trkLink, vtx))) continue;
178  if ( (*trkLink)->pt() >m_trkMaxPt) continue;
179  float jetPt=0.0;
180  float minDr=10.0;
181 
182  for (const xAOD::Jet* jet : *jetCont) {
183  if (jet->pt() < m_jetMinPt) {continue;} //skip jets below pT threshold
184  float DR = xAOD::P4Helpers::deltaR(*trkLink, jet);
185  if(DR<minDr) {
186  minDr = DR;
187  jetPt = jet->pt();
188  }
189  }
190  if(minDr <= m_jetTrkMaxDr){//check if jet is within dR 1.
191  sum = m_sum->add(sum, (*trkLink)->pt(),jetPt,minDr );
192  }
193  }
194  if (sum > maxsum) {
195  maxsum = sum;
196  hardscatter = vtx;
197  }
198  }
199  //::keeping Matt's (old) method for sumpt & sumpt2
200  else {
201  for (const auto& trkLink : vtx->trackParticleLinks()) {
202  if (trkLink.isValid()) {
203  if (m_doTrkSelection && !static_cast<bool>(m_trkSelectTool->accept(**trkLink, vtx))) continue;
204  sum = m_sum->add(sum, (*trkLink)->pt(),0.,0.);
205  }
206  }
207  if (sum > maxsum) {
208  maxsum = sum;
209  hardscatter = vtx;
210  }
211  }
212  }
213  // Else, return the PV:
214  else {
215  if (vtx->vertexType() == xAOD::VxType::PriVtx) {
216  hardscatter = vtx;
217  break;
218  }
219  }
220  }
221 
222  return hardscatter;
223 }

◆ getHardScatterLink() [1/2]

ElementLink< xAOD::VertexContainer > InDet::InDetHardScatterSelectionTool::getHardScatterLink ( ) const
overridevirtual

Implements InDet::IInDetHardScatterSelectionTool.

Definition at line 254 of file InDetHardScatterSelectionTool.cxx.

255 {
256  const EventContext& ctx = Gaudi::Hive::currentContext();
258  if (!vtxCont.isValid()) {
259  ATH_MSG_ERROR("Could not open primary vertex container, returning empty ElementLink!");
260  return {};
261  }
262  return getHardScatterLink(vtxCont.get());
263 }

◆ getHardScatterLink() [2/2]

ElementLink< xAOD::VertexContainer > InDet::InDetHardScatterSelectionTool::getHardScatterLink ( const xAOD::VertexContainer vtxCont) const
overridevirtual

Function for returning the hardscatter vertex link.

Implements InDet::IInDetHardScatterSelectionTool.

Definition at line 236 of file InDetHardScatterSelectionTool.cxx.

237 {
238  ATH_MSG_DEBUG("In getHardScatterLink(...) for " << name() << "...");
239 
240  const EventContext& ctx = Gaudi::Hive::currentContext();
241 
242  // Get our hardscatter vertex
243  const xAOD::Vertex* hardscatter = getHardScatter(vtxCont);
244 
245  // Create our element link
246  ElementLink<xAOD::VertexContainer> hardscatterLink;
247  if (hardscatter) {
248  hardscatterLink.toContainedElement(*vtxCont, hardscatter, ctx);
249  }
250 
251  return hardscatterLink;
252 }

◆ getKey()

SG::sgkey_t asg::AsgTool::getKey ( const void *  ptr) const
inherited

Get the (hashed) key of an object that is in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::TEvent both provide ways for getting the SG::sgkey_t key for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getName
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The hashed key of the object in the store. If not found, an invalid (zero) key.

Definition at line 119 of file AsgTool.cxx.

119  {
120 
121 #ifdef XAOD_STANDALONE
122  // In case we use @c xAOD::TEvent, we have a direct function call
123  // for this.
124  return evtStore()->event()->getKey( ptr );
125 #else
126  const SG::DataProxy* proxy = evtStore()->proxy( ptr );
127  return ( proxy == nullptr ? 0 : proxy->sgkey() );
128 #endif // XAOD_STANDALONE
129  }

◆ getName()

const std::string & asg::AsgTool::getName ( const void *  ptr) const
inherited

Get the name of an object that is / should be in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::TEvent both provide ways for getting the std::string name for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getKey
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The string name of the object in the store. If not found, an empty string.

Definition at line 106 of file AsgTool.cxx.

106  {
107 
108 #ifdef XAOD_STANDALONE
109  // In case we use @c xAOD::TEvent, we have a direct function call
110  // for this.
111  return evtStore()->event()->getName( ptr );
112 #else
113  const SG::DataProxy* proxy = evtStore()->proxy( ptr );
114  static const std::string dummy = "";
115  return ( proxy == nullptr ? dummy : proxy->name() );
116 #endif // XAOD_STANDALONE
117  }

◆ getProperty()

template<class T >
const T* asg::AsgTool::getProperty ( const std::string &  name) const
inherited

Get one of the tool's properties.

◆ initialize()

StatusCode InDet::InDetHardScatterSelectionTool::initialize ( )
overridevirtual

Function initialising the tool.

Reimplemented from asg::AsgTool.

Definition at line 54 of file InDetHardScatterSelectionTool.cxx.

55 {
56  // Print configuration
57  ATH_MSG_DEBUG("Initializing " << name() << "...");
58  ATH_MSG_DEBUG("Using RedoHardScatter: " << m_redoHardScatter);
59  ATH_MSG_DEBUG("Using SelectionMode: " << m_mode);
60  ATH_MSG_DEBUG("Using TrackSelectionTool: " << m_trkSelectTool);
61  ATH_MSG_DEBUG("Using ReturnDeco: " << m_returnDeco);
62  ATH_MSG_DEBUG("Using HardScatterLinkDeco: " << m_hardScatterDeco.toString());
63  ATH_MSG_DEBUG("Using VertexContainer: " << m_vtxContKey);
64  ATH_MSG_DEBUG("Using JetContainer: " << m_jetContKey);
65 
67  ATH_MSG_ERROR("RedoHardScatter and ReturnDeco cannot both be set to true.");
68  return StatusCode::FAILURE;
69  }
70 
71  // If we are re-doing the hardscatter
72  if (m_redoHardScatter) {
73  ATH_MSG_DEBUG("Setting the hard scatter strategy to: " << m_mode);
74 
75  // Determine how we will sum the track pt
76  switch (m_mode) {
77  case InDet::InDetHardScatterSelectionTool::Mode::SumPt2: {
78  m_sum = std::make_unique<::SumPt2>();
79  break;
80  }
81  case InDet::InDetHardScatterSelectionTool::Mode::SumPt: {
82  m_sum = std::make_unique<::SumPt>();
83  break;
84  }
85  case InDet::InDetHardScatterSelectionTool::Mode::SumPtw: {
86  m_sum = std::make_unique<::SumPtw>();
87  break;
88  }
89  default: {
90  ATH_MSG_ERROR("Unknown running mode : " << m_mode);
91  return StatusCode::FAILURE;
92  }
93  }
94 
95  // Fetch our InDetTrackSelectionTool
96  if (m_redoHardScatter && !m_trkSelectTool.empty()) {
97  m_doTrkSelection = true;
98  ATH_CHECK(m_trkSelectTool.retrieve());
99  }
100 
101  }
102 
103  // If we are returning a decoration
104  else if (m_returnDeco) {
105  if (m_hardScatterDeco.empty()) {
106  ATH_MSG_ERROR("Hardscatter vertex decoration cannot be empty!");
107  return StatusCode::FAILURE;
108  }
109  }
110 
111  // Initialize our EventInfo container and decoration reads
115 
116  // Initialize our vertex container read
117  ATH_CHECK(m_vtxContKey.initialize());
118 
119  // Initialize our jet container read if it is non empty
120  ATH_CHECK(m_jetContKey.initialize(!m_jetContKey.empty()));
121 
122  return StatusCode::SUCCESS;
123 }

◆ 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.

◆ 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  }

◆ msg_level_name()

const std::string & asg::AsgTool::msg_level_name ( ) const
inherited

A deprecated function for getting the message level's name.

Instead of using this, weirdly named function, user code should get the string name of the current minimum message level (in case they really need it...), with:

MSG::name( msg().level() )

This function's name doesn't follow the ATLAS coding rules, and as such will be removed in the not too distant future.

Returns
The string name of the current minimum message level that's printed

Definition at line 101 of file AsgTool.cxx.

101  {
102 
103  return MSG::name( msg().level() );
104  }

◆ 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.

◆ print()

void asg::AsgTool::print ( ) const
virtualinherited

◆ 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

◆ 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_doTrkSelection

bool InDet::InDetHardScatterSelectionTool::m_doTrkSelection = false
private

A flag which will be true if an InDetTrackSelectionTool was provided.

Definition at line 130 of file InDetHardScatterSelectionTool.h.

◆ m_evtInfoKey

SG::ReadHandleKey<xAOD::EventInfo> InDet::InDetHardScatterSelectionTool::m_evtInfoKey {this, "EventInfo", "EventInfo", "EventInfo key"}
private

xAOD::EventInfo ReadHandleKey

Definition at line 133 of file InDetHardScatterSelectionTool.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_hardScatterDeco

StringProperty InDet::InDetHardScatterSelectionTool::m_hardScatterDeco {this, "HardScatterLinkDeco", "hardScatterVertexLink", "The decoration name of the ElementLink to the hardscatter vertex (applied to xAOD::EventInfo)"}
private

Definition at line 141 of file InDetHardScatterSelectionTool.h.

◆ m_hardScatterDecoKey

SG::ReadDecorHandleKey<xAOD::EventInfo> InDet::InDetHardScatterSelectionTool::m_hardScatterDecoKey {this, "VertexScatterKey", "" , "Overwrriten in the configuration step by the <HardScatterLinkDeco> property"}
private

The decoration name of the ElementLink to the hardscatter vertex (applied to xAOD::EventInfo)

Definition at line 147 of file InDetHardScatterSelectionTool.h.

◆ m_jetContKey

SG::ReadHandleKey<xAOD::JetContainer> InDet::InDetHardScatterSelectionTool::m_jetContKey { this, "JetContainer", "AntiKt4EMTopoJets", "Name of the jet container" }
private

Definition at line 135 of file InDetHardScatterSelectionTool.h.

◆ m_jetMinPt

FloatProperty InDet::InDetHardScatterSelectionTool::m_jetMinPt {this, "jetMinPt", 15000.0, "minimum jet pt"}
private

Definition at line 142 of file InDetHardScatterSelectionTool.h.

◆ m_jetTrkMaxDr

FloatProperty InDet::InDetHardScatterSelectionTool::m_jetTrkMaxDr {this, "jetTrkMaxDr", 0.8, "max dR between jet & Trk"}
private

Definition at line 143 of file InDetHardScatterSelectionTool.h.

◆ m_mode

IntegerProperty InDet::InDetHardScatterSelectionTool::m_mode { this, "SelectionMode", InDet::InDetHardScatterSelectionTool::Mode::SumPt2, "Mode for selecting the hardscatter: sumpt2[0] or sumpt[1] or sumptw[2]"}
private

Definition at line 138 of file InDetHardScatterSelectionTool.h.

◆ m_redoHardScatter

BooleanProperty InDet::InDetHardScatterSelectionTool::m_redoHardScatter { this, "RedoHardScatter", false, "If true, redo the hardscatter selection using sumpt2 or sumpt or sumptw"}
private

Definition at line 137 of file InDetHardScatterSelectionTool.h.

◆ m_returnDeco

BooleanProperty InDet::InDetHardScatterSelectionTool::m_returnDeco { this, "ReturnDeco", false, "If true, return the hardscatter as the vertex decorated with some boolean"}
private

Definition at line 140 of file InDetHardScatterSelectionTool.h.

◆ m_sum

std::unique_ptr<Sum> InDet::InDetHardScatterSelectionTool::m_sum
private

A helper class which either sums pt2 or pt or ptw.

Definition at line 127 of file InDetHardScatterSelectionTool.h.

◆ m_trkMaxPt

FloatProperty InDet::InDetHardScatterSelectionTool::m_trkMaxPt {this, "trkMaxPt", 10045000, "max track pt"}
private

Definition at line 144 of file InDetHardScatterSelectionTool.h.

◆ m_trkSelectTool

ToolHandle<InDet::IInDetTrackSelectionTool> InDet::InDetHardScatterSelectionTool::m_trkSelectTool {this, "TrackSelectionTool", "InDet::InDetTrackSelectionTool/TrackSelectionTool", "Track selection tool to use"}
private

Definition at line 139 of file InDetHardScatterSelectionTool.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.

◆ m_vtxContKey

SG::ReadHandleKey<xAOD::VertexContainer> InDet::InDetHardScatterSelectionTool::m_vtxContKey {this, "VertexContainer", "PrimaryVertices", "Name of the primary vertex container"}
private

Definition at line 134 of file InDetHardScatterSelectionTool.h.


The documentation for this class was generated from the following files:
asg::AsgTool
Base class for the dual-use tool implementation classes.
Definition: AsgTool.h:47
InDet::InDetHardScatterSelectionTool::getHardScatterLink
ElementLink< xAOD::VertexContainer > getHardScatterLink() const override
Definition: InDetHardScatterSelectionTool.cxx:254
InDet::InDetHardScatterSelectionTool::m_hardScatterDecoKey
SG::ReadDecorHandleKey< xAOD::EventInfo > m_hardScatterDecoKey
The decoration name of the ElementLink to the hardscatter vertex (applied to xAOD::EventInfo)
Definition: InDetHardScatterSelectionTool.h:147
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
InDet::InDetHardScatterSelectionTool::SumPt2
@ SumPt2
Definition: InDetHardScatterSelectionTool.h:61
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
InDet::InDetHardScatterSelectionTool::m_jetContKey
SG::ReadHandleKey< xAOD::JetContainer > m_jetContKey
Definition: InDetHardScatterSelectionTool.h:135
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore::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
InDet::InDetHardScatterSelectionTool::SumPt
@ SumPt
Definition: InDetHardScatterSelectionTool.h:62
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
InDet::InDetHardScatterSelectionTool::m_trkMaxPt
FloatProperty m_trkMaxPt
Definition: InDetHardScatterSelectionTool.h:144
InDet::InDetHardScatterSelectionTool::m_jetMinPt
FloatProperty m_jetMinPt
Definition: InDetHardScatterSelectionTool.h:142
InDet::InDetHardScatterSelectionTool::getHardScatter
const xAOD::Vertex * getHardScatter() const override
Definition: InDetHardScatterSelectionTool.cxx:225
InDet::InDetHardScatterSelectionTool::SumPtw
@ SumPtw
Definition: InDetHardScatterSelectionTool.h:63
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
InDet::InDetHardScatterSelectionTool::m_redoHardScatter
BooleanProperty m_redoHardScatter
Definition: InDetHardScatterSelectionTool.h:137
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
AthCommonDataStore
Definition: AthCommonDataStore.h:52
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition: StoreGate/StoreGate/ReadDecorHandle.h:94
xAOD::P4Helpers::deltaR
double deltaR(double rapidity1, double phi1, double rapidity2, double phi2)
from bare bare rapidity,phi
Definition: xAODP4Helpers.h:150
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
InDet::InDetHardScatterSelectionTool::m_doTrkSelection
bool m_doTrkSelection
A flag which will be true if an InDetTrackSelectionTool was provided.
Definition: InDetHardScatterSelectionTool.h:130
InDet::InDetHardScatterSelectionTool::m_mode
IntegerProperty m_mode
Definition: InDetHardScatterSelectionTool.h:138
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition: TrackingPrimitives.h:571
InDet::InDetHardScatterSelectionTool::m_vtxContKey
SG::ReadHandleKey< xAOD::VertexContainer > m_vtxContKey
Definition: InDetHardScatterSelectionTool.h:134
InDet::InDetHardScatterSelectionTool::m_evtInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_evtInfoKey
xAOD::EventInfo ReadHandleKey
Definition: InDetHardScatterSelectionTool.h:133
InDet::InDetHardScatterSelectionTool::m_returnDeco
BooleanProperty m_returnDeco
Definition: InDetHardScatterSelectionTool.h:140
python.xAODType.dummy
dummy
Definition: xAODType.py:4
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MSG::name
const std::string & name(Level lvl)
Convenience function for translating message levels to strings.
Definition: MsgLevel.cxx:19
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
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
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
InDet::InDetHardScatterSelectionTool::m_hardScatterDeco
StringProperty m_hardScatterDeco
Definition: InDetHardScatterSelectionTool.h:141
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
InDet::InDetHardScatterSelectionTool::m_trkSelectTool
ToolHandle< InDet::IInDetTrackSelectionTool > m_trkSelectTool
Definition: InDetHardScatterSelectionTool.h:139
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
a
TList * a
Definition: liststreamerinfos.cxx:10
h
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
InDet::InDetHardScatterSelectionTool::m_sum
std::unique_ptr< Sum > m_sum
A helper class which either sums pt2 or pt or ptw.
Definition: InDetHardScatterSelectionTool.h:127
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
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
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
SG::DataProxy
Definition: DataProxy.h:44
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
InDet::InDetHardScatterSelectionTool::m_jetTrkMaxDr
FloatProperty m_jetTrkMaxDr
Definition: InDetHardScatterSelectionTool.h:143
fitman.k
k
Definition: fitman.py:528