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

#include <JetClustererByVertex.h>

Inheritance diagram for JetClustererByVertex:
Collaboration diagram for JetClustererByVertex:

Public Member Functions

 JetClustererByVertex (const std::string &name)
StatusCode initialize () override
 Dummy implementation of the initialisation function.
std::pair< std::unique_ptr< xAOD::JetContainer >, std::unique_ptr< SG::IAuxStore > > getJets () const override
 Return the final jets with their aux store.
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
StatusCode getAndRecordJets (SG::WriteHandle< xAOD::JetContainer > &jetHandle) const
 Method to allow the client to pass in a WriteHandle for the container and aux container to be recorded, while the client remains free to modify the output but does not need to know the type of the aux container.
virtual StatusCode initWithOutput (const SG::WriteHandleKey< xAOD::JetContainer > &)
 Method to allow the client to pass in a WriteHandle during initialisation, in case this is needed for anything...
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

fastjet::AreaDefinition buildAreaDefinition (bool &seedsok) const
 Build the area definition when running with area calculation. The seedsok flag is set to false when error occurs when retrieving event/run number to initiate the seeds.
std::unique_ptr< fastjet::ClusterSequence > buildClusterSequence (const PseudoJetVector *pseudoJetvector) const
 Used to create the cluster sequence.
void processPseudoJet (const fastjet::PseudoJet &pj, const PseudoJetContainer &pjCont, xAOD::JetContainer *jets, const xAOD::Vertex *vertex) const
 translate to xAOD::Jet
bool isVariableR () const
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.

Protected Attributes

SG::ReadHandleKey< xAOD::EventInfom_eventinfokey {"EventInfo"}
 Handle to EventInfo. This is used to get the evt&run number to set the Ghost area random seeds.
SG::ReadHandleKey< PseudoJetContainerm_inputPseudoJets {this, "InputPseudoJets", "inputpseudojet", "input constituents"}
 Handle Input PseudoJetContainer.
SG::WriteHandleKey< PseudoJetVectorm_finalPseudoJets {this, "FinalPseudoJets_DONOTSET", "", "output pseudojets -- autoconfigured name"}
 used to build the key under which the final PJ will be stored in evtStore()
SG::WriteHandleKey< jet::ClusterSequencem_clusterSequence {this, "ClusterSequence_DONOTSET", "", "output pseudojets -- autoconfigured name"}
Gaudi::Property< std::string > m_jetRank {this, "jetRankName", "jetRank", "name for accessor for jet rank"}
Gaudi::Property< std::string > m_jetalg {this, "JetAlgorithm", "AntiKt", "alg type : AntiKt, Kt, CA..."}
Gaudi::Property< float > m_jetrad {this, "JetRadius", 0.4 , "jet size parameter"}
Gaudi::Property< float > m_ptmin {this, "PtMin", 0.0, "pT min in MeV"}
Gaudi::Property< float > m_ghostarea {this, "GhostArea", 0.0, "Area for ghosts. 0==>no ghosts."}
Gaudi::Property< int > m_ranopt {this, "RandomOption", 1, "Rand option: 0=fj default, 1=run/event"}
Gaudi::Property< int > m_inputType {this, "JetInputType", 0, "input type as in xAOD::JetInput (see xAODJet/JetContainerInfo.h)"}
fastjet::JetAlgorithm m_fjalg
bool m_useArea {}
Gaudi::Property< float > m_minrad {this, "VariableRMinRadius", -1.0, "Variable-R min radius" }
Gaudi::Property< float > m_massscale {this, "VariableRMassScale", -1.0, "Variable-R mass scale" }
bool m_isVariableR {}
SG::AuxElement::Accessor< int > m_jetRankAccessor

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

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::VertexContainerm_vertexContainer_key {this, "VertexContainer", "PrimaryVertices", "SG key for input vertex container"}
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

Definition at line 43 of file JetClustererByVertex.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

◆ JetClustererByVertex()

JetClustererByVertex::JetClustererByVertex ( const std::string & name)

Definition at line 26 of file JetClustererByVertex.cxx.

26: JetClusterer(myname) {}
JetClusterer(const std::string &name)

Member Function Documentation

◆ buildAreaDefinition()

fastjet::AreaDefinition JetClusterer::buildAreaDefinition ( bool & seedsok) const
protectedinherited

Build the area definition when running with area calculation. The seedsok flag is set to false when error occurs when retrieving event/run number to initiate the seeds.

Definition at line 271 of file JetClusterer.cxx.

272{
273
274 fastjet::GhostedAreaSpec gspec(5.0, 1, m_ghostarea);
275 seedsok = true;
276 std::vector<int> seeds;
277
278 if (m_ranopt == 1)
279 {
280 // Use run/event number as random number seeds.
281 auto evtInfoHandle = SG::makeHandle(m_eventinfokey);
282 if (!evtInfoHandle.isValid())
283 {
284 ATH_MSG_ERROR("Unable to retrieve event info");
285 seedsok = false;
286 return {};
287 }
288
289 JetClustererHelper::seedsFromEventInfo(evtInfoHandle.cptr(), seeds);
290 }
291
292 ATH_MSG_DEBUG("Active area specs:");
293 ATH_MSG_DEBUG(" Requested ghost area: " << m_ghostarea);
294 ATH_MSG_DEBUG(" Actual ghost area: " << gspec.actual_ghost_area());
295 ATH_MSG_DEBUG(" Max eta: " << gspec.ghost_etamax());
296 ATH_MSG_DEBUG(" # ghosts: " << gspec.n_ghosts());
297 ATH_MSG_DEBUG(" # rapidity bins: " << gspec.nrap());
298 ATH_MSG_DEBUG(" # phi bins: " << gspec.nphi());
299
300 if (seeds.size() == 2)
301 {
302 ATH_MSG_DEBUG(" Random seeds: " << seeds[0] << ", " << seeds[1]);
303 }
304 else
305 {
306 ATH_MSG_WARNING("Random generator size is not 2: " << seeds.size());
307 ATH_MSG_DEBUG(" Random seeds: ");
308 for (auto seed : seeds)
309 ATH_MSG_DEBUG(" " << seed);
310 }
311
312 // We use with_fixed_seed() as recommended for thread safety in
313 // fastjet 3.4.0.
314 return fastjet::AreaDefinition(fastjet::active_area,
315 gspec)
316 .with_fixed_seed(seeds);
317}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Gaudi::Property< float > m_ghostarea
SG::ReadHandleKey< xAOD::EventInfo > m_eventinfokey
Handle to EventInfo. This is used to get the evt&run number to set the Ghost area random seeds.
Gaudi::Property< int > m_ranopt
void seedsFromEventInfo(const xAOD::EventInfo *ei, std::vector< int > &seeds)
Fill seeds vector from run & event number. This functio is separated from the class so it's easier to...
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())

◆ buildClusterSequence()

std::unique_ptr< fastjet::ClusterSequence > JetClusterer::buildClusterSequence ( const PseudoJetVector * pseudoJetvector) const
protectedinherited

Used to create the cluster sequence.

Definition at line 91 of file JetClusterer.cxx.

92{
93
94 fastjet::JetDefinition jetdef(m_fjalg, m_jetrad);
95 using fastjet::contrib::VariableRPlugin;
96 std::unique_ptr<VariableRPlugin> VRJetPlugin(nullptr);
97
98 if (m_isVariableR)
99 {
100 /* clustering algorithm
101 * They correspond to p parameter of Sequential recombination algs
102 * AKTLIKE = -1, CALIKE = 0, KTLIKE = 1
103 */
104 VariableRPlugin::ClusterType VRClusterType = VariableRPlugin::AKTLIKE;
105 switch (m_fjalg)
106 {
107 case fastjet::kt_algorithm:
108 VRClusterType = VariableRPlugin::KTLIKE;
109 break;
110 case fastjet::antikt_algorithm:
111 VRClusterType = VariableRPlugin::AKTLIKE;
112 break;
113 case fastjet::cambridge_algorithm:
114 VRClusterType = VariableRPlugin::CALIKE;
115 break;
116 default:
117 ATH_MSG_ERROR("Unsupported clustering algorithm for Variable-R jet finding.");
118 return nullptr;
119 }
120 VRJetPlugin = std::make_unique<VariableRPlugin>(m_massscale, m_minrad, m_jetrad, VRClusterType, false);
121 jetdef = fastjet::JetDefinition(VRJetPlugin.get());
122 }
123
124 std::unique_ptr<fastjet::ClusterSequence> clSequence(nullptr);
125
126 if (m_useArea)
127 {
128 // Prepare ghost area specifications -------------
129 ATH_MSG_DEBUG("Creating input area cluster sequence");
130 bool seedsok = true;
131 fastjet::AreaDefinition adef = buildAreaDefinition(seedsok);
132
133 if (seedsok)
134 {
135 clSequence = std::make_unique<fastjet::ClusterSequenceArea>(*pseudoJetVector, jetdef, adef);
136 }
137 else
138 {
139 return nullptr;
140 }
141 }
142 else
143 {
144 ATH_MSG_DEBUG("Creating input cluster sequence");
145 clSequence = std::make_unique<fastjet::ClusterSequence>(*pseudoJetVector, jetdef);
146 }
147
148 return clSequence;
149}
fastjet::AreaDefinition buildAreaDefinition(bool &seedsok) const
Build the area definition when running with area calculation. The seedsok flag is set to false when e...
Gaudi::Property< float > m_massscale
Gaudi::Property< float > m_minrad
Gaudi::Property< float > m_jetrad
fastjet::JetAlgorithm m_fjalg

◆ 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

◆ getAndRecordJets()

StatusCode JetProvider< xAOD::JetAuxContainer >::getAndRecordJets ( SG::WriteHandle< xAOD::JetContainer > & jetHandle) const
inlinevirtualinherited

Method to allow the client to pass in a WriteHandle for the container and aux container to be recorded, while the client remains free to modify the output but does not need to know the type of the aux container.

Every class derived from IJetProvider needs to implement the record, providing the explicit type – we should give StoreGate maximal information rather than recording AuxContainerBase

The recommended solution is for the concrete tool to inherit from the templated JetProvider class provided below.

Implements IJetProvider.

Definition at line 81 of file IJetProvider.h.

81 {
85 if(jets.get()==nullptr || auxCont.get()==nullptr) {return StatusCode::FAILURE;}
86
87 // Convert the aux container pointer to the known base class
89
90 // Write out JetContainer and JetAuxContainer
92 }
virtual std::pair< std::unique_ptr< xAOD::JetContainer >, std::unique_ptr< SG::IAuxStore > > getJets() const=0
Concrete class that implements the recording of jets & aux container to StoreGate via an externally p...

◆ getJets()

std::pair< std::unique_ptr< xAOD::JetContainer >, std::unique_ptr< SG::IAuxStore > > JetClustererByVertex::getJets ( ) const
overridevirtual

Return the final jets with their aux store.

Can return a pair of null pointers if an error occurs.

Reimplemented from JetClusterer.

Definition at line 37 of file JetClustererByVertex.cxx.

38{
39 // Return this in case of any problems
40 auto nullreturn = std::make_pair(std::unique_ptr<xAOD::JetContainer>(nullptr), std::unique_ptr<SG::IAuxStore>(nullptr));
41
42 // -----------------------
43 // retrieve input
44 SG::ReadHandle<PseudoJetContainer> pjContHandle(m_inputPseudoJets);
45 if (!pjContHandle.isValid())
46 {
47 ATH_MSG_ERROR("No valid PseudoJetContainer with key " << m_inputPseudoJets.key());
48 return nullreturn;
49 }
50
51 // Get reco vertices
52 SG::ReadHandle<xAOD::VertexContainer> vertexHandle = SG::makeHandle(m_vertexContainer_key);
53 const xAOD::VertexContainer *vertices = vertexHandle.cptr();
54 unsigned numVertices = vertices->size();
55 ATH_MSG_DEBUG("Retrieved vertex container for by-vertex clustering");
56
57 // Build the container to be returned
58 // Avoid memory leaks with unique_ptr
59 auto jets = std::make_unique<xAOD::JetContainer>();
60 auto auxCont = std::make_unique<xAOD::JetAuxContainer>();
61 jets->setStore(auxCont.get());
62
63 // Create a copy of the PseudoJet container that we modify for each vertex
64 // There is no valid copy constructor, but can use the `append` method instead
65 PseudoJetContainer pjContCopy;
66 pjContCopy.append(pjContHandle.cptr());
67
68 // The pointer to the PseudoJetVector (non-const) that we can modify for each iteration
69 PseudoJetVector *inputPseudoJetVector = pjContCopy.casVectorPseudoJet();
70 // We need to keep a copy of the original vector, otherwise we will lose information
71 const PseudoJetVector cachedPseudoJetVector(*inputPseudoJetVector);
72
73 ATH_MSG_DEBUG("Pseudojet input container has size " << inputPseudoJetVector->size());
74
75 std::unique_ptr<fastjet::ClusterSequence> clSequence = std::make_unique<fastjet::ClusterSequence>();
76
77 std::unique_ptr<PseudoJetVector> outputPseudoJetVector = std::make_unique<PseudoJetVector>();
78
79 for (unsigned int iVertex{0}; iVertex < numVertices; iVertex++)
80 {
81 const xAOD::Vertex *vertex = vertices->at(iVertex);
82
83 for (unsigned int iJet{0}; iJet < inputPseudoJetVector->size(); iJet++)
84 {
85 fastjet::PseudoJet &pseudoJet = inputPseudoJetVector->at(iJet);
86 // Check if pseudoJet has VertexIndexedConstituentUserInfo
87 if (pseudoJet.has_user_info<jet::VertexIndexedConstituentUserInfo>())
88 {
89 const jet::VertexIndexedConstituentUserInfo &userInfo = pseudoJet.user_info<jet::VertexIndexedConstituentUserInfo>();
90 const xAOD::Vertex *originVertex = userInfo.vertex();
91 // Reset state
92 pseudoJet = cachedPseudoJetVector.at(iJet);
93 if (originVertex != vertex)
94 {
95 // pseudoJet should not affect this vertex iteration
96 // nullify its four-momentum
97 pseudoJet *= 1e-12;
98 }
99 else
100 {
101 // Do nothing -- this is the correct vertex
102 ATH_MSG_VERBOSE("Constituent found with pT = " << pseudoJet.pt() << " belonging to vertex index: " << userInfo.vertex()->index());
103 }
104 }
105 // Else we expect this to be a ghost, so do nothing
106 }
107 std::unique_ptr<fastjet::ClusterSequence> clSequenceByVertex = buildClusterSequence(inputPseudoJetVector);
108 if (!clSequenceByVertex)
109 return nullreturn;
110
111 // -----------------------
112 // Build a new pointer to a PseudoJetVector containing the final PseudoJet
113 // This allows us to own the vector of PseudoJet which we will put in the evt store.
114 // Thus the contained PseudoJet will be kept frozen there and we can safely use pointer to them from the xAOD::Jet objects
115
116 auto outputPseudoJetVectorByVertex = std::make_unique<PseudoJetVector>(fastjet::sorted_by_pt(clSequenceByVertex->inclusive_jets(m_ptmin)));
117 if (msgLvl(MSG::VERBOSE))
118 {
119 for (const auto &pj : *outputPseudoJetVectorByVertex)
120 {
121 msg() << " Pseudojet with pt " << std::setprecision(4) << pj.Et() * 1e-3 << " has " << pj.constituents().size() << " constituents" << endmsg;
122 }
123 }
124
125 // No PseudoJets, so there's nothing else to do
126 // Delete the cluster sequence before we go
127 if (!outputPseudoJetVectorByVertex->empty())
128 {
129 for (const fastjet::PseudoJet &pj : *outputPseudoJetVectorByVertex)
130 {
131 processPseudoJet(pj, pjContCopy, jets.get(), vertex);
132 //Mario we need to add jetRank for btagging
133 // we want the rank to start with zero, but this is after the
134 // jet has been added, thus the "size() - 1" here.
135 m_jetRankAccessor(*jets.get()->back()) = jets->size() - 1;
136 }
137 }
138 ATH_MSG_DEBUG("For vertex index " << iVertex << ", total reconstructed jet count so far: " << jets->size() << " clusterseq=" << clSequenceByVertex.get());
139
140 // Copy the contents of pjVectorByVertex into pjVector
141 for (const fastjet::PseudoJet &pj : *outputPseudoJetVectorByVertex)
142 {
143 outputPseudoJetVector->emplace_back(pj);
144 }
145
146 // We want to add the clSequence from this vertex to the total one
147 // TODO: how to best achieve this?
148 // Looks like this will simply delete the old sequence..
149 // clSequence->transfer_from_sequence(*clSequenceByVertex);
150 }
151
152 if (!outputPseudoJetVector->empty())
153 {
154 // -------------------------------------
155 // record final PseudoJetVector
156 SG::WriteHandle<PseudoJetVector> pjVectorHandle(m_finalPseudoJets);
157 if (!pjVectorHandle.record(std::move(outputPseudoJetVector)))
158 {
159 ATH_MSG_ERROR("Can't record PseudoJetVector under key " << m_finalPseudoJets);
160 return nullreturn;
161 }
162 // -------------------------------------
163 // record ClusterSequences vector
164 SG::WriteHandle<jet::ClusterSequence> clusterSeqHandle(m_clusterSequence);
165 if (!clusterSeqHandle.record(std::move(clSequence)))
166 {
167 ATH_MSG_ERROR("Can't record ClusterSequence under key " << m_clusterSequence);
168 return nullreturn;
169 }
170 }
171
172 // Return the jet container and aux, use move to transfer
173 // ownership of pointers to caller
174 return std::make_pair(std::move(jets), std::move(auxCont));
175}
#define endmsg
#define ATH_MSG_VERBOSE(x)
std::vector< fastjet::PseudoJet > PseudoJetVector
bool msgLvl(const MSG::Level lvl) const
const T * at(size_type n) const
Access an element, as an rvalue.
size_type size() const noexcept
Returns the number of elements in the collection.
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexContainer_key
SG::WriteHandleKey< jet::ClusterSequence > m_clusterSequence
Gaudi::Property< float > m_ptmin
void processPseudoJet(const fastjet::PseudoJet &pj, const PseudoJetContainer &pjCont, xAOD::JetContainer *jets, const xAOD::Vertex *vertex) const
translate to xAOD::Jet
SG::AuxElement::Accessor< int > m_jetRankAccessor
std::unique_ptr< fastjet::ClusterSequence > buildClusterSequence(const PseudoJetVector *pseudoJetvector) const
Used to create the cluster sequence.
SG::ReadHandleKey< PseudoJetContainer > m_inputPseudoJets
Handle Input PseudoJetContainer.
SG::WriteHandleKey< PseudoJetVector > m_finalPseudoJets
used to build the key under which the final PJ will be stored in evtStore()
const std::vector< PseudoJet > * casVectorPseudoJet() const
void append(const PseudoJetContainer *)
size_t index() const
Return the index of this element within its container.
const_pointer_type cptr()
Dereference the pointer.
const xAOD::Vertex * vertex() const
Returns the associated vertex if this constit is a track. Else returns null. *‍/.
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
MsgStream & msg
Definition testRead.cxx:32

◆ 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 JetClustererByVertex::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 JetClusterer.

Definition at line 28 of file JetClustererByVertex.cxx.

29{
31 ATH_CHECK(m_vertexContainer_key.initialize());
33
34 return StatusCode::SUCCESS;
35}
#define ATH_CHECK
Evaluate an expression and check for errors.
Gaudi::Property< std::string > m_jetRank
StatusCode initialize() override
Dummy implementation of the initialisation function.
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572

◆ initWithOutput()

virtual StatusCode IJetProvider::initWithOutput ( const SG::WriteHandleKey< xAOD::JetContainer > & )
inlinevirtualinherited

Method to allow the client to pass in a WriteHandle during initialisation, in case this is needed for anything...

The main (only?) use case is for copying jets, and propagating any decorations already on the original to the copy in StoreGate

Quietly return success in the general case – the JetRecAlg will always call this, so as to remain agnostic as to the concrete type.

Reimplemented in JetCopier.

Definition at line 65 of file IJetProvider.h.

65{return StatusCode::SUCCESS;};

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

◆ isVariableR()

bool JetClusterer::isVariableR ( ) const
inlineprotectedinherited

Definition at line 102 of file JetClusterer.h.

102{ return m_isVariableR;}

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

◆ processPseudoJet()

void JetClusterer::processPseudoJet ( const fastjet::PseudoJet & pj,
const PseudoJetContainer & pjCont,
xAOD::JetContainer * jets,
const xAOD::Vertex * vertex ) const
protectedinherited

translate to xAOD::Jet

Definition at line 151 of file JetClusterer.cxx.

152{
153
154 // -------------------------------------
155 // translate to xAOD::Jet
156 ATH_MSG_DEBUG("Converting pseudojets to xAOD::Jet");
157 static const SG::AuxElement::Accessor<const fastjet::PseudoJet *> pjAccessor("PseudoJet");
158 PseudoJetTranslator pjTranslator(m_useArea, m_useArea);
159
160 // create the xAOD::Jet from the PseudoJet, doing the signal & constituents extraction
161 xAOD::Jet &jet = pjTranslator.translate(pj, pjCont, *jets, originVertex);
162
163 // Add the PseudoJet onto the xAOD jet. Maybe we should do it in the above JetFromPseudojet call ??
164 pjAccessor(jet) = &pj;
165
168 jet.setAlgorithmType(ialg);
169 jet.setSizeParameter(m_jetrad.value());
170 if (m_isVariableR)
171 {
174 }
175 if (m_useArea)
177
178 ATH_MSG_VERBOSE(" xAOD::Jet with pt " << std::setprecision(4) << jet.pt() * 1e-3 << " has " << jet.getConstituents().size() << " constituents");
179 ATH_MSG_VERBOSE(" Leading constituent is of type " << jet.getConstituents()[0].rawConstituent()->type());
180
181 // Perhaps better to make configurable
182 if (originVertex)
183 {
184 jet.setAssociatedObject("OriginVertex", originVertex);
185 }
186 else
187 {
188 ATH_MSG_VERBOSE("Could not set OriginVertex for jet!");
189 }
190}
Gaudi::Property< int > m_inputType
size_t size() const
number of constituents
void setAlgorithmType(JetAlgorithmType::ID a)
Definition Jet_v1.cxx:258
void setAttribute(const std::string &name, const T &v)
JetConstituentVector getConstituents() const
Return a vector of consituents. The object behaves like vector<const IParticle*>. See JetConstituentV...
Definition Jet_v1.cxx:147
virtual double pt() const
The transverse momentum ( ) of the particle.
Definition Jet_v1.cxx:44
void setSizeParameter(float p)
Definition Jet_v1.cxx:257
void setInputType(JetInput::Type t)
Definition Jet_v1.cxx:259
void setAssociatedObject(const std::string &name, const T *vec)
set a single associated object T must inherit AuxElement (if T inherits IParticle,...
ID algId(const std::string &n)
Converts a string into a JetAlgorithmType::ID.
ID
//////////////////////////////////////// JetAlgorithmType::ID defines most common physics jet finding...
Jet_v1 Jet
Definition of the current "jet version".

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

SG::WriteHandleKey<jet::ClusterSequence> JetClusterer::m_clusterSequence {this, "ClusterSequence_DONOTSET", "", "output pseudojets -- autoconfigured name"}
protectedinherited

Definition at line 82 of file JetClusterer.h.

82{this, "ClusterSequence_DONOTSET", "", "output pseudojets -- autoconfigured name"};

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

SG::ReadHandleKey<xAOD::EventInfo> JetClusterer::m_eventinfokey {"EventInfo"}
protectedinherited

Handle to EventInfo. This is used to get the evt&run number to set the Ghost area random seeds.

Definition at line 75 of file JetClusterer.h.

75{"EventInfo"};

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

SG::WriteHandleKey<PseudoJetVector> JetClusterer::m_finalPseudoJets {this, "FinalPseudoJets_DONOTSET", "", "output pseudojets -- autoconfigured name"}
protectedinherited

used to build the key under which the final PJ will be stored in evtStore()

Definition at line 81 of file JetClusterer.h.

81{this, "FinalPseudoJets_DONOTSET", "", "output pseudojets -- autoconfigured name"};

◆ m_fjalg

fastjet::JetAlgorithm JetClusterer::m_fjalg
protectedinherited

Definition at line 96 of file JetClusterer.h.

◆ m_ghostarea

Gaudi::Property<float> JetClusterer::m_ghostarea {this, "GhostArea", 0.0, "Area for ghosts. 0==>no ghosts."}
protectedinherited

Definition at line 89 of file JetClusterer.h.

89{this, "GhostArea", 0.0, "Area for ghosts. 0==>no ghosts."};

◆ m_inputPseudoJets

SG::ReadHandleKey<PseudoJetContainer> JetClusterer::m_inputPseudoJets {this, "InputPseudoJets", "inputpseudojet", "input constituents"}
protectedinherited

Handle Input PseudoJetContainer.

Definition at line 78 of file JetClusterer.h.

78{this, "InputPseudoJets", "inputpseudojet", "input constituents"};

◆ m_inputType

Gaudi::Property<int> JetClusterer::m_inputType {this, "JetInputType", 0, "input type as in xAOD::JetInput (see xAODJet/JetContainerInfo.h)"}
protectedinherited

Definition at line 92 of file JetClusterer.h.

92{this, "JetInputType", 0, "input type as in xAOD::JetInput (see xAODJet/JetContainerInfo.h)"};

◆ m_isVariableR

bool JetClusterer::m_isVariableR {}
protectedinherited

Definition at line 101 of file JetClusterer.h.

101{};

◆ m_jetalg

Gaudi::Property<std::string> JetClusterer::m_jetalg {this, "JetAlgorithm", "AntiKt", "alg type : AntiKt, Kt, CA..."}
protectedinherited

Definition at line 86 of file JetClusterer.h.

86{this, "JetAlgorithm", "AntiKt", "alg type : AntiKt, Kt, CA..."};

◆ m_jetrad

Gaudi::Property<float> JetClusterer::m_jetrad {this, "JetRadius", 0.4 , "jet size parameter"}
protectedinherited

Definition at line 87 of file JetClusterer.h.

87{this, "JetRadius", 0.4 , "jet size parameter"};

◆ m_jetRank

Gaudi::Property<std::string> JetClusterer::m_jetRank {this, "jetRankName", "jetRank", "name for accessor for jet rank"}
protectedinherited

Definition at line 83 of file JetClusterer.h.

83{this, "jetRankName", "jetRank", "name for accessor for jet rank"};

◆ m_jetRankAccessor

SG::AuxElement::Accessor<int> JetClusterer::m_jetRankAccessor
protectedinherited

Definition at line 104 of file JetClusterer.h.

◆ m_massscale

Gaudi::Property<float> JetClusterer::m_massscale {this, "VariableRMassScale", -1.0, "Variable-R mass scale" }
protectedinherited

Definition at line 100 of file JetClusterer.h.

100{this, "VariableRMassScale", -1.0, "Variable-R mass scale" };

◆ m_minrad

Gaudi::Property<float> JetClusterer::m_minrad {this, "VariableRMinRadius", -1.0, "Variable-R min radius" }
protectedinherited

Definition at line 99 of file JetClusterer.h.

99{this, "VariableRMinRadius", -1.0, "Variable-R min radius" };

◆ m_ptmin

Gaudi::Property<float> JetClusterer::m_ptmin {this, "PtMin", 0.0, "pT min in MeV"}
protectedinherited

Definition at line 88 of file JetClusterer.h.

88{this, "PtMin", 0.0, "pT min in MeV"};

◆ m_ranopt

Gaudi::Property<int> JetClusterer::m_ranopt {this, "RandomOption", 1, "Rand option: 0=fj default, 1=run/event"}
protectedinherited

Definition at line 90 of file JetClusterer.h.

90{this, "RandomOption", 1, "Rand option: 0=fj default, 1=run/event"};

◆ m_useArea

bool JetClusterer::m_useArea {}
protectedinherited

Definition at line 97 of file JetClusterer.h.

97{};

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vertexContainer_key

SG::ReadHandleKey<xAOD::VertexContainer> JetClustererByVertex::m_vertexContainer_key {this, "VertexContainer", "PrimaryVertices", "SG key for input vertex container"}
private

Definition at line 59 of file JetClustererByVertex.h.

59{this, "VertexContainer", "PrimaryVertices", "SG key for input vertex container"};

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