ATLAS Offline Software
Loading...
Searching...
No Matches
JetGrooming::RecSoftDrop Class Reference

A specialized SoftDrop tool wrapping fastjet::contrib::RecursiveSoftDrop. More...

#include <JetSoftDropTools.h>

Inheritance diagram for JetGrooming::RecSoftDrop:
Collaboration diagram for JetGrooming::RecSoftDrop:

Public Member Functions

StatusCode initialize () override final
 Dummy implementation of the initialisation function.
virtual void insertGroomedJet (const xAOD::Jet &, const PseudoJetContainer &, xAOD::JetContainer &, PseudoJetVector &) const override final
virtual std::pair< std::unique_ptr< xAOD::JetContainer >, std::unique_ptr< SG::IAuxStore > > getJets () const override final
 Method to build the collection and return it to the caller.
 AsgTool (const std::string &name)
 Constructor specifying the tool instance's name.
 AsgTool (const AsgTool &)=delete
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

void setSoftDropAttributes (xAOD::Jet &groomedjet, int nsdsubjets) 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

Gaudi::Property< float > m_zcut {this, "ZCut", 0.1 , "pT fraction for retaining subjets"}
Gaudi::Property< float > m_beta {this, "Beta", 0.0, "How much to consider angular dependence"}
Gaudi::Property< float > m_R0 {this, "R0", 1.0, "Normalization of angular distance, usually the characteristic jet radius (default R0 = 1)"}
Gaudi::Property< bool > m_saveSDatt {this, "SaveSoftDropAttributes",false, ""}
SG::ReadHandleKey< xAOD::JetContainerm_inputJetContainer {this, "UngroomedJets", "ungroomedinput", "Input ungroomed jet container"}
 Handle Input JetContainer (this contains the parent ungroomed jets to be trimmed)
SG::ReadHandleKey< PseudoJetContainerm_inputPseudoJets {this, "ParentPseudoJets", "inputpseudojet", "input constituents of parent JetContainer"}
 This is the input to the parent JetContainer. It is needed in order to re-assign the ghost constituents from the final groomed PJ to the xAOD::Jet.
SG::WriteHandleKey< PseudoJetVectorm_finalPseudoJets {this, "FinalPseudoJets_DONOTSET", "", "output pseudojets -- autoconfigured name"}

Private Attributes

Gaudi::Property< int > m_N {this, "N", 1 , "Number of layers (-1 <> infinite)"}

Detailed Description

A specialized SoftDrop tool wrapping fastjet::contrib::RecursiveSoftDrop.

Definition at line 64 of file JetSoftDropTools.h.

Member Function Documentation

◆ AsgTool() [1/2]

asg::AsgTool::AsgTool ( const AsgTool & )
deleteinherited

◆ AsgTool() [2/2]

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

Constructor specifying the tool instance's name.

Definition at line 51 of file AsgTool.cxx.

60#ifndef XAOD_STANDALONE
61 ::getType(name), ::getName(name), ::getParent(name)
62#else // not XAOD_STANDALONE
63 name
64#endif // not XAOD_STANDALONE
65 )
66#ifdef XAOD_STANDALONE
67 , m_event()
68#endif // XAOD_STANDALONE
69 {
70 ToolStore::put( this ).ignore(); // Register the tool in the ToolStore
71 }
const std::string & getName(const void *ptr) const
Get the name of an object that is / should be in the event store.
Definition AsgTool.cxx:106
::AthAlgTool AsgToolBase
Definition AsgTool.h:33

◆ 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 > > JetGroomer::getJets ( ) const
finaloverridevirtualinherited

Method to build the collection and return it to the caller.

Unique_ptrs are used to avoid potential memory leaks. The aux container is returned as an IAuxStore pointer to support operations such as shallow copy.

Implements IJetProvider.

Definition at line 43 of file JetGroomer.cxx.

43 {
44 // Return this in case of any problems
45 auto nullreturn = std::make_pair(std::unique_ptr<xAOD::JetContainer>(nullptr), std::unique_ptr<SG::IAuxStore>(nullptr));
46
47 // -----------------------
48 // retrieve input
49 SG::ReadHandle<xAOD::JetContainer> jetContHandle(m_inputJetContainer);
50 if(!jetContHandle.isValid()) {
51 ATH_MSG_ERROR("No valid JetContainer with key "<< m_inputJetContainer.key());
52 return nullreturn;
53 }
54
55 SG::ReadHandle<PseudoJetContainer> pjContHandle(m_inputPseudoJets);
56 if(!pjContHandle.isValid()) {
57 ATH_MSG_ERROR("No valid PseudoJetContainer with key "<< m_inputPseudoJets.key());
58 return nullreturn;
59 }
60
61 // Build the container to be returned
62 // Avoid memory leaks with unique_ptr
63 auto groomedJets = std::make_unique<xAOD::JetContainer>();
64 auto auxCont = std::make_unique<xAOD::JetAuxContainer>();
65 groomedJets->setStore(auxCont.get());
66
67 // -----------------------
68 // Build a new pointer to a PseudoJetVector containing the final groomed PseudoJets
69 // This allows us to own the vector of PseudoJet which we will put in the evt store.
70 // Thus the contained PseudoJet will be kept frozen there and we can safely use pointer to them from the xAOD::Jet objects
71 auto groomPJVector = std::make_unique<PseudoJetVector>( );
72 groomPJVector->resize( jetContHandle->size() );
73
74 // loop over input jets
75 for (const xAOD::Jet* parentJet: *jetContHandle){
76 // Child will create a groomed jet and insert it into the output container
77 this->insertGroomedJet(*parentJet, *pjContHandle, *groomedJets, *groomPJVector);
78 }
79
80 // -------------------------------------
81 // record final PseudoJetVector
82 SG::WriteHandle<PseudoJetVector> pjVectorHandle(m_finalPseudoJets);
83 if(!pjVectorHandle.record(std::move(groomPJVector))){
84 ATH_MSG_ERROR("Can't record PseudoJetVector under key "<< m_finalPseudoJets);
85 return nullreturn;
86 }
87
88 return std::make_pair(std::move(groomedJets),std::move(auxCont));
89}
#define ATH_MSG_ERROR(x)
SG::ReadHandleKey< PseudoJetContainer > m_inputPseudoJets
This is the input to the parent JetContainer. It is needed in order to re-assign the ghost constituen...
Definition JetGroomer.h:58
virtual void insertGroomedJet(const xAOD::Jet &, const PseudoJetContainer &, xAOD::JetContainer &, PseudoJetVector &) const =0
SG::WriteHandleKey< PseudoJetVector > m_finalPseudoJets
Definition JetGroomer.h:60
SG::ReadHandleKey< xAOD::JetContainer > m_inputJetContainer
Handle Input JetContainer (this contains the parent ungroomed jets to be trimmed)
Definition JetGroomer.h:55
Jet_v1 Jet
Definition of the current "jet version".

◆ 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 RecSoftDrop::initialize ( void )
finaloverridevirtual

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 JetGrooming::JetGroomer.

Definition at line 76 of file JetSoftDropTools.cxx.

76 {
78 CHECK_VAR_RANGE("N", m_N, (m_zcut>-1) );
79 return StatusCode::SUCCESS;
80}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define CHECK_VAR_RANGE(name, var, expr)
Gaudi::Property< int > m_N
StatusCode initialize() override
Dummy implementation of the initialisation function.
Gaudi::Property< float > m_zcut

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

◆ insertGroomedJet()

void RecSoftDrop::insertGroomedJet ( const xAOD::Jet & parentjet,
const PseudoJetContainer & inpjcont,
xAOD::JetContainer & outcont,
PseudoJetVector & groomedpjvec ) const
finaloverridevirtual

Reimplemented from JetGrooming::SoftDrop.

Definition at line 109 of file JetSoftDropTools.cxx.

109 {
110
111 //configure recursive soft drop tool
112 //https://fastjet.hepforge.org/trac/browser/contrib/contribs/RecursiveTools/tags/2.0.0-beta1
113 fastjet::contrib::RecursiveSoftDrop softdropper(m_beta, m_zcut, m_N, m_R0);
114
115 xAOD::Jet & jet = buildAndInsertSDJet(softdropper,
116 parentjet, inpjcont, outcont, groomedpjvec);
117
118 if(m_saveSDatt) {
119 setSoftDropAttributes(jet, groomedpjvec[jet.index()].pieces().size() );
120 jet.setAttribute<int>("RSoftDropN", m_N);
121 }
122}
Gaudi::Property< float > m_R0
Gaudi::Property< float > m_beta
void setSoftDropAttributes(xAOD::Jet &groomedjet, int nsdsubjets) const
Gaudi::Property< bool > m_saveSDatt
size_t index() const
Return the index of this element within its container.
void setAttribute(const std::string &name, const T &v)

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

◆ setSoftDropAttributes()

void SoftDrop::setSoftDropAttributes ( xAOD::Jet & groomedjet,
int nsdsubjets ) const
protectedinherited

Definition at line 97 of file JetSoftDropTools.cxx.

97 {
98 groomedjet.setAttribute<float>("ZCut", m_zcut);
99 groomedjet.setAttribute<float>("SoftDropBeta", m_beta);
100 groomedjet.setAttribute<float>("SoftDropR0", m_R0);
101 groomedjet.setAttribute<int>("NSoftDropSubjets", nsdsubjets);
102}

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

Gaudi::Property<float> JetGrooming::SoftDrop::m_beta {this, "Beta", 0.0, "How much to consider angular dependence"}
protectedinherited

Definition at line 52 of file JetSoftDropTools.h.

52{this, "Beta", 0.0, "How much to consider angular dependence"};

◆ m_finalPseudoJets

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

Definition at line 60 of file JetGroomer.h.

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

◆ m_inputJetContainer

SG::ReadHandleKey<xAOD::JetContainer> JetGrooming::JetGroomer::m_inputJetContainer {this, "UngroomedJets", "ungroomedinput", "Input ungroomed jet container"}
protectedinherited

Handle Input JetContainer (this contains the parent ungroomed jets to be trimmed)

Definition at line 55 of file JetGroomer.h.

55{this, "UngroomedJets", "ungroomedinput", "Input ungroomed jet container"};

◆ m_inputPseudoJets

SG::ReadHandleKey<PseudoJetContainer> JetGrooming::JetGroomer::m_inputPseudoJets {this, "ParentPseudoJets", "inputpseudojet", "input constituents of parent JetContainer"}
protectedinherited

This is the input to the parent JetContainer. It is needed in order to re-assign the ghost constituents from the final groomed PJ to the xAOD::Jet.

Definition at line 58 of file JetGroomer.h.

58{this, "ParentPseudoJets", "inputpseudojet", "input constituents of parent JetContainer"};

◆ m_N

Gaudi::Property<int> JetGrooming::RecSoftDrop::m_N {this, "N", 1 , "Number of layers (-1 <> infinite)"}
private

Definition at line 74 of file JetSoftDropTools.h.

74{this, "N", 1 , "Number of layers (-1 <> infinite)"};

◆ m_R0

Gaudi::Property<float> JetGrooming::SoftDrop::m_R0 {this, "R0", 1.0, "Normalization of angular distance, usually the characteristic jet radius (default R0 = 1)"}
protectedinherited

Definition at line 53 of file JetSoftDropTools.h.

53{this, "R0", 1.0, "Normalization of angular distance, usually the characteristic jet radius (default R0 = 1)"};

◆ m_saveSDatt

Gaudi::Property<bool> JetGrooming::SoftDrop::m_saveSDatt {this, "SaveSoftDropAttributes",false, ""}
protectedinherited

Definition at line 55 of file JetSoftDropTools.h.

55{this, "SaveSoftDropAttributes",false, ""};

◆ m_zcut

Gaudi::Property<float> JetGrooming::SoftDrop::m_zcut {this, "ZCut", 0.1 , "pT fraction for retaining subjets"}
protectedinherited

Definition at line 51 of file JetSoftDropTools.h.

51{this, "ZCut", 0.1 , "pT fraction for retaining subjets"};

The documentation for this class was generated from the following files: