ATLAS Offline Software
Loading...
Searching...
No Matches
HIJetDRAssociationTool Class Reference

JetModifier that stores links to IParticles w/in DR of a jet. In HIJetRec this association is needed to determine which clusters t.o exclude from the HIEventShape recalculation on the basis of some seed jets May not want to only use constituents of seed jets, e.g. R=0.2 jets as seeds but want to exclude DR=0.6 around jet position, track jets, etc. More...

#include <HIJetDRAssociationTool.h>

Inheritance diagram for HIJetDRAssociationTool:
Collaboration diagram for HIJetDRAssociationTool:

Public Member Functions

 HIJetDRAssociationTool (const std::string &t)
virtual StatusCode initialize () override
 Dummy implementation of the initialisation function.
virtual StatusCode modify (xAOD::JetContainer &jets) const override
 Implementing abstract methods from base.
virtual int modifyJet (xAOD::Jet &) const override
 Implementing abstract methods from base, not used.
virtual void print () const
 Print the state of the tool.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const
Additional helper functions, not directly mimicking Athena
template<class T>
const T * getProperty (const std::string &name) const
 Get one of the tool's properties.
const std::string & msg_level_name () const __attribute__((deprecated))
 A deprecated function for getting the message level's name.
const std::string & getName (const void *ptr) const
 Get the name of an object that is / should be in the event store.
SG::sgkey_t getKey (const void *ptr) const
 Get the (hashed) key of an object that is in the event store.

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
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.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

 ASG_TOOL_CLASS0 (HIJetDRAssociationTool)
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

SG::ReadHandleKey< xAOD::IParticleContainerm_containerKey { this, "ContainerKey", "", "Name of IParticleContainer w/ particles to associate"}
 name of IParticleContainer w/ particles to associate
Gaudi::Property< std::string > m_assocName { this, "AssociationName", "" , "Name of jet attribute providing link between jets and IParticles" }
 Name of jet attribute providing link between jets and IParticles.
Gaudi::Property< float > m_DR { this, "DeltaR", 0.8, "DR cut defining association" }
 DR cut defining association.
Gaudi::Property< bool > m_applyFilter { this, "ApplyFilter",false, "Flag to enable kinematic requirements on associated IParticle" }
 Flag to enable kinematic requirements on associated IParticle.
Gaudi::Property< float > m_Emin { this, "FilterMinE", -999., "Minimum E requirement for associated IParticle, in addition to DR" }
 Minimum E requirement for associated IParticle, in addition to DR.
Gaudi::Property< float > m_pTmin { this, "FilterMinPt", 0., "Minimum pT requirement for associated IParticle, in addition to DR" }
 Minimum pT requirement for associated IParticle, in addition to DR.
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

JetModifier that stores links to IParticles w/in DR of a jet. In HIJetRec this association is needed to determine which clusters t.o exclude from the HIEventShape recalculation on the basis of some seed jets May not want to only use constituents of seed jets, e.g. R=0.2 jets as seeds but want to exclude DR=0.6 around jet position, track jets, etc.

Author
Aaron Angerami anger.nosp@m.ami@.nosp@m.cern..nosp@m.ch
Date
Jan, 2015

Tool can also be used for generic DR associations as an alternative to ghost associations.

Definition at line 32 of file HIJetDRAssociationTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ HIJetDRAssociationTool()

HIJetDRAssociationTool::HIJetDRAssociationTool ( const std::string & t)

Definition at line 10 of file HIJetDRAssociationTool.cxx.

12{
13}
JetModifierBase(const std::string &myname)
Ctor.

Member Function Documentation

◆ ASG_TOOL_CLASS0()

HIJetDRAssociationTool::ASG_TOOL_CLASS0 ( HIJetDRAssociationTool )
private

◆ declareGaudiProperty()

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

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

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

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

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

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

◆ evtStore()

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.

◆ 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

◆ 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 }
ServiceHandle< StoreGateSvc > & evtStore()

◆ 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 HIJetDRAssociationTool::initialize ( void )
overridevirtual

Dummy implementation of the initialisation function.

It's here to allow the dual-use tools to skip defining an initialisation function. Since many are doing so...

Reimplemented from asg::AsgTool.

Definition at line 17 of file HIJetDRAssociationTool.cxx.

18{
19 ATH_MSG_VERBOSE("HIJetDRAssociationTool initialize");
20 ATH_CHECK( m_containerKey.initialize( !m_containerKey.key().empty() ) );
21 return StatusCode::SUCCESS;
22}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
SG::ReadHandleKey< xAOD::IParticleContainer > m_containerKey
name of IParticleContainer w/ particles to associate

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

◆ modify()

StatusCode HIJetDRAssociationTool::modify ( xAOD::JetContainer & jets) const
overridevirtual

Implementing abstract methods from base.

Reimplemented from JetModifierBase.

Definition at line 26 of file HIJetDRAssociationTool.cxx.

27{
28
29 const xAOD::IParticleContainer* ppars=0;
30
31 ATH_MSG_DEBUG("Retrieving xAOD container " << m_containerKey.key() );
32 SG::ReadHandle<xAOD::IParticleContainer> readHandlePcontainer ( m_containerKey );
33 ppars = readHandlePcontainer.get();
34
35 using Grid=std::vector<std::vector<std::vector<const xAOD::IParticle*>>>;
36 const double etaMin = -5;
37 const double etaMax = 5;
38 const double phiMin = -3.1416;
39 const double phiMax = 3.1416;
40
41 // build square grid
42 Grid grid;
43 grid.resize(1+ (etaMax-etaMin)/m_DR);
44 for ( auto& phiVec: grid) {
45 phiVec.resize(1+ (phiMax-phiMin)/m_DR);
46 }
47
48 auto etaToIndex = [etaMin, this](double eta) -> size_t { return (eta-etaMin)/m_DR; };
49 auto phiToIndex = [phiMin, this](double phi) -> size_t { return (phi-phiMin)/m_DR; };
50
51 auto neighborsInEta = [&grid, etaToIndex](double eta) -> std::vector<size_t> {
52 const size_t etaIndex = etaToIndex(eta);
53 if ( etaIndex == 0){
54 return {etaIndex, etaIndex+1};
55 }
56 if ( etaIndex == grid.size()-1){
57 return {etaIndex-1, etaIndex};
58 }
59 return {etaIndex-1, etaIndex, etaIndex+1};
60 };
61
62 auto neighborsInPhi = [&grid, phiToIndex](double phi) -> std::vector<size_t> {
63 const size_t phiIndex = phiToIndex(phi);
64 if ( phiIndex == 0){
65 return {grid[0].size()-1, phiIndex, phiIndex+1};
66 }
67 if ( phiIndex == grid[0].size()-1){
68 return {phiIndex-1, phiIndex, 0ul}; // wrapping condition
69 }
70 return {phiIndex-1, phiIndex, phiIndex+1};
71 };
72
73 for(const auto* ap : *ppars) {
74 grid[etaToIndex(ap->eta())][phiToIndex(ap->phi())].push_back(ap);
75 }
76
77 for (xAOD::JetContainer::iterator ijet=jets.begin(); ijet!=jets.end(); ++ijet)
78 {
79 std::vector<const xAOD::IParticle*> ParticleVector;
80 xAOD::Jet* theJet=(*ijet);
81 auto etaN = neighborsInEta(theJet->eta());
82 auto phiN = neighborsInPhi(theJet->phi());
83
84 for ( size_t etaI : etaN) {
85 for ( size_t phiI : phiN ) {
86 for ( auto ap: grid[etaI][phiI]) {
87 if(theJet->p4().DeltaR( ap->p4()) < m_DR) ParticleVector.push_back(ap);
88 }
89 }
90 }
92 }
93 return StatusCode::SUCCESS;
94}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_DEBUG(x)
std::vector< const IParticle * > ParticleVector
const T * get(size_type n) const
Access an element, as an rvalue.
DataModel_detail::iterator< DataVector > iterator
Definition DataVector.h:842
Gaudi::Property< float > m_DR
DR cut defining association.
Gaudi::Property< std::string > m_assocName
Name of jet attribute providing link between jets and IParticles.
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition Jet_v1.cxx:54
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition Jet_v1.cxx:71
void setAssociatedObjects(const std::string &name, const std::vector< const T * > &vec)
set associated objects from a vector of arbitrary object.
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition Jet_v1.cxx:49
unsigned long ul
unsigned int phiIndex(float phi, float binsize)
calculate phi index for a given phi
Definition EtaPhiLUT.cxx:23
Jet_v1 Jet
Definition of the current "jet version".
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.

◆ modifyJet()

virtual int HIJetDRAssociationTool::modifyJet ( xAOD::Jet & ) const
inlineoverridevirtual

Implementing abstract methods from base, not used.

Reimplemented from JetModifierBase.

Definition at line 47 of file HIJetDRAssociationTool.h.

47{return 1;};

◆ msg()

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

Definition at line 24 of file AthCommonMsg.h.

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

◆ 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 }
MsgStream & msg() const
const std::string & name(Level lvl)
Convenience function for translating message levels to strings.
Definition MsgLevel.cxx:19

◆ 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()

◆ 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();
384 }
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)

◆ 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 {
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 asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ 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) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_applyFilter

Gaudi::Property< bool > HIJetDRAssociationTool::m_applyFilter { this, "ApplyFilter",false, "Flag to enable kinematic requirements on associated IParticle" }
private

Flag to enable kinematic requirements on associated IParticle.

Definition at line 60 of file HIJetDRAssociationTool.h.

60{ this, "ApplyFilter",false, "Flag to enable kinematic requirements on associated IParticle" };

◆ m_assocName

Gaudi::Property< std::string > HIJetDRAssociationTool::m_assocName { this, "AssociationName", "" , "Name of jet attribute providing link between jets and IParticles" }
private

Name of jet attribute providing link between jets and IParticles.

Definition at line 55 of file HIJetDRAssociationTool.h.

55{ this, "AssociationName", "" , "Name of jet attribute providing link between jets and IParticles" };

◆ m_containerKey

SG::ReadHandleKey< xAOD::IParticleContainer > HIJetDRAssociationTool::m_containerKey { this, "ContainerKey", "", "Name of IParticleContainer w/ particles to associate"}
private

name of IParticleContainer w/ particles to associate

Definition at line 52 of file HIJetDRAssociationTool.h.

52{ this, "ContainerKey", "", "Name of IParticleContainer w/ particles to associate"};

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

Gaudi::Property< float > HIJetDRAssociationTool::m_DR { this, "DeltaR", 0.8, "DR cut defining association" }
private

DR cut defining association.

Definition at line 58 of file HIJetDRAssociationTool.h.

58{ this, "DeltaR", 0.8, "DR cut defining association" };

◆ m_Emin

Gaudi::Property< float > HIJetDRAssociationTool::m_Emin { this, "FilterMinE", -999., "Minimum E requirement for associated IParticle, in addition to DR" }
private

Minimum E requirement for associated IParticle, in addition to DR.

Definition at line 62 of file HIJetDRAssociationTool.h.

62{ this, "FilterMinE", -999., "Minimum E requirement for associated IParticle, in addition to DR" };

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

Gaudi::Property< float > HIJetDRAssociationTool::m_pTmin { this, "FilterMinPt", 0., "Minimum pT requirement for associated IParticle, in addition to DR" }
private

Minimum pT requirement for associated IParticle, in addition to DR.

Definition at line 64 of file HIJetDRAssociationTool.h.

64{ this, "FilterMinPt", 0., "Minimum pT requirement for associated IParticle, in addition to DR" };

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