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

#include <JetRecTool.h>

Inheritance diagram for JetRecTool:

Public Member Functions

 JetRecTool (const std::string &myname)
StatusCode initialize () override
 Initialization. Check all tools here.
virtual const xAOD::JetContainerbuild () const override
 Retrieve inputs with tools and construct new jet collection.
int execute () const override
 Call build and put jets in event store.
void print () const override
 Display the configuration.
int inputContainerNames (std::vector< std::string > &connames) override
 Method to return the list of input containers.
int outputContainerNames (std::vector< std::string > &connames) override
 Method to return the list of output containers.
void setInputJetContainer (const xAOD::JetContainer *cont)
 For trigger usage in grooming mode only : give the input ungroomed jet container.
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

std::unique_ptr< xAOD::JetContainerfillOutputContainer () const
std::unique_ptr< PseudoJetContainercollectPseudoJets () const
const xAOD::JetContainergetOldJets () const
std::unique_ptr< xAOD::JetContainermakeOutputContainer () const
std::unique_ptr< xAOD::JetContainerfindJets () const
std::unique_ptr< xAOD::JetContainergroomJets () const
std::unique_ptr< xAOD::JetContainercopyJets () const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

SG::WriteHandleKey< xAOD::JetContainerm_outcoll {this, "OutputContainer", ""}
SG::ReadHandleKey< xAOD::JetContainerm_incoll {this, "InputContainer", ""}
SG::ReadHandleKeyArray< PseudoJetContainerm_psjsin {this, "InputPseudoJets", {}}
ToolHandle< IJetExecuteToolm_intool
ToolHandle< IJetPseudojetRetrieverm_hpjr
ToolHandle< IJetFinderm_finder
ToolHandle< IJetGroomerm_groomer
ToolHandleArray< IJetModifierm_modifiers {this, "JetModifiers", {}}
ToolHandleArray< IJetConsumerm_consumers {this, "JetConsumers", {}}
bool m_trigger {}
int m_initCount {}
bool m_find {}
bool m_groom {}
bool m_copy {}
xAOD::JetInput::Type m_inputtype
IJetFinder::NameList m_ghostlabs
std::vector< std::string > m_incolls
std::vector< std::string > m_outcolls
const IJetPseudojetRetrieverm_ppjr {}
const xAOD::JetContainerm_trigInputJetsForGrooming {}
ToolHandle< GenericMonitoringToolm_monTool {this,"MonTool","","Monitoring tool"}
const double m_mevtogev = 0.001
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

Author
David Adams.
Date
January 2014

This is the top-level tool for jet reconstruction. It creates a new jet collection from finding, grooming or copy. There is a one-to-one correpondence between jet collections and JetRecTool instances.

Properties are as follows: OutputContainer: Name of the output jet collection InputCollection: Name of the input jet collection. Required for grooming or copy. If InputTool is defined, the collection name is taked from the output collection name of that tool. The configured value of this property should be identical to that or blank. InputPseudoJets: Array of ReadHandleKeys for the pseudojet collections to be retrieved and passed to JetFinder. These collections are merged and used as input for jet finding. InputTool: Handle for the JetRecTool called to create the input collection if it is not already found in the event store. JetPseudojetRetriever: Tool used to retrieve the pseudojet cluster sequence associated with a jet. If undefined, one is created. JetFinder: Handle for the tool used to find jets. JetGroomer: Handle for the tool used to groom jets. JetModifiers: Array of handles of tools used to modify the jet collection, e.g. to add moments sort or filter. JetConsumers: Tools consuming jets to run after building jets

This tool may be used to build jets in any one of three ways:

  1. To find jets, the JetFinder and PseudoJetGetters must be defined. InputCollection, InputTool and JetGroomer should not be defined.
  2. To groom jets, the JetGroomer and InputCollection or InputTool must be defined. The JetFinder should not be defined.
  3. To copy jets, the InputCollection or InputTool must be defined. The tool may also be used to call a sequence of pseudojet builders without building any jets. In this case, none of OutputCollection, InputCollection, InputTool, JetFinder or jetGroomer should be defined and the array of jet modifiers should be empty.

Definition at line 68 of file JetRecTool.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

◆ JetRecTool()

JetRecTool::JetRecTool ( const std::string & myname)

Definition at line 42 of file JetRecTool.cxx.

43: AsgTool(myname),
44 m_intool("",this),
45#ifdef XAOD_ANALYSIS
46 m_hpjr("",this),
47#else
48 m_hpjr("JetPseudojetRetriever/jpjr",this),
49#endif
50 m_finder("",this),
51 m_groomer("",this),
52 m_trigger(false),
53 m_initCount(0),
54 m_find(false), m_groom(false), m_copy(false),
56 m_ppjr(nullptr) {
57 declareProperty("InputTool", m_intool);
58 declareProperty("JetPseudojetRetriever", m_hpjr);
59 declareProperty("JetFinder", m_finder);
60 declareProperty("JetGroomer", m_groomer);
61 declareProperty("Trigger", m_trigger);
62}
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ToolHandle< IJetFinder > m_finder
Definition JetRecTool.h:128
xAOD::JetInput::Type m_inputtype
Definition JetRecTool.h:139
ToolHandle< IJetPseudojetRetriever > m_hpjr
Definition JetRecTool.h:127
ToolHandle< IJetExecuteTool > m_intool
Definition JetRecTool.h:126
int m_initCount
Definition JetRecTool.h:135
bool m_trigger
Definition JetRecTool.h:132
const IJetPseudojetRetriever * m_ppjr
Definition JetRecTool.h:143
ToolHandle< IJetGroomer > m_groomer
Definition JetRecTool.h:129
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58

Member Function Documentation

◆ build()

const JetContainer * JetRecTool::build ( ) const
overridevirtual

Retrieve inputs with tools and construct new jet collection.

Implements IJetBuildTool.

Definition at line 217 of file JetRecTool.cxx.

217 {
218 if ( m_initCount == 0 ) {
219 ATH_MSG_WARNING("Build requested before initialization.");
220 return nullptr;
221 }
222 ATH_MSG_DEBUG("Building jets with " << name() << ".");
223
224 std::unique_ptr<xAOD::JetContainer> pjets = fillOutputContainer();
225
226 SG::WriteHandle<xAOD::JetContainer> jetsHandle(m_outcoll);
227
228 // Record the jet collection.
229 if(m_trigger){
230 #ifndef GENERATIONBASE
231 std::unique_ptr<xAOD::JetTrigAuxContainer> pjetsaux(dynamic_cast<xAOD::JetTrigAuxContainer*>( pjets->getStore() ));
232 ATH_MSG_DEBUG("Check Aux store: " << pjets.get() << " ... " << &pjets->auxbase() << " ... " << pjetsaux.get() );
233 if ( pjetsaux.get() == nullptr ) {
234 ATH_MSG_ERROR("Unable to retrieve Aux container");
235 return nullptr;
236 }
237 ATH_MSG_VERBOSE("Recording new Jet and Aux container.");
238 if(jetsHandle.record(std::move(pjets), std::move(pjetsaux)).isFailure()){
239 // TODO - put this back how it was
240 ATH_MSG_ERROR("Unable to write new Jet collection and aux store to event store: " << m_outcoll.key());
241 return nullptr;
242 }
243 #endif
244 }
245 else{
246 std::unique_ptr<xAOD::JetAuxContainer> pjetsaux(dynamic_cast<xAOD::JetAuxContainer*>( pjets->getStore() ));
247 ATH_MSG_DEBUG("Check Aux store: " << pjets.get() << " ... " << &pjets->auxbase() << " ... " << pjetsaux.get() );
248 if ( pjetsaux.get() == nullptr ) {
249 ATH_MSG_ERROR("Unable to retrieve Aux container");
250 return nullptr;
251 }
252 ATH_MSG_VERBOSE("Recording new Jet and Aux container.");
253 if(jetsHandle.record(std::move(pjets), std::move(pjetsaux)).isFailure()){
254 ATH_MSG_ERROR("Unable to write new Jet collection and aux store to event store: " << m_outcoll.key());
255 return nullptr;
256 }
257 }
258 ATH_MSG_DEBUG("Created new Jet collection in event store: " << m_outcoll.key());
259
260 // Modify jets.
261 unsigned int nmod = m_modifiers.size();
262 if ( nmod ) {
263 if ( !jetsHandle.isValid() ) {
264 ATH_MSG_WARNING("There is no jet collection to modify.");
265 } else {
266 ATH_MSG_DEBUG("Executing " << nmod << " jet modifiers.");
267 for ( ModifierArray::const_iterator imod=m_modifiers.begin();
268 imod!=m_modifiers.end(); ++imod ) {
269 ATH_MSG_DEBUG(" Executing modifier " << imod->name());
270 ATH_MSG_VERBOSE(" @ " << *imod);
271 if((*imod)->modify(*jetsHandle).isFailure())
272 ATH_MSG_DEBUG(" Modifier returned FAILURE!");
273 }
274 }
275 }
276
277 // Consume jets.
278 unsigned int ncon = m_consumers.size();
279 if ( ncon ) {
280 if ( !jetsHandle.isValid() ) {
281 ATH_MSG_WARNING("There is no jet collection to consume");
282 } else {
283 ATH_MSG_DEBUG("Executing " << ncon << " jet consumers.");
284 for ( ConsumerArray::const_iterator icon=m_consumers.begin();
285 icon!=m_consumers.end(); ++icon ) {
286 ATH_MSG_DEBUG(" Executing consumer " << icon->name());
287 ATH_MSG_VERBOSE(" @ " << *icon);
288 (*icon)->process(*jetsHandle) ;
289 }
290 }
291 }
292
293
294#if !defined (GENERATIONBASE) && !defined (XAOD_ANALYSIS)
295 // monitor jet multiplicity and basic jet kinematics
296 auto njets = Monitored::Scalar<int>("JET_n");
297 auto pt = Monitored::Collection("JET_pt", *jetsHandle, [c=m_mevtogev]( const xAOD::Jet* jet ) { return jet->pt()*c; });
298 auto et = Monitored::Collection("JET_et", *jetsHandle, [c=m_mevtogev]( const xAOD::Jet* jet ) { return jet->p4().Et()*c; });
299 auto mass = Monitored::Collection("JET_m", *jetsHandle, [c=m_mevtogev]( const xAOD::Jet* jet ) { return jet->m()*c; });
300 auto eta = Monitored::Collection("JET_eta", *jetsHandle, []( const xAOD::Jet* jet ) { return jet->eta(); });
301 auto phi = Monitored::Collection("JET_phi", *jetsHandle, []( const xAOD::Jet* jet ) { return jet->phi(); });
302 auto mon = Monitored::Group(m_monTool,njets,pt,et,mass,eta,phi);
303 njets = jetsHandle->size();
304#endif
305
306 return jetsHandle.isValid() ? &(*jetsHandle) : nullptr;
307}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
float et(const xAOD::jFexSRJetRoI *j)
SG::WriteHandleKey< xAOD::JetContainer > m_outcoll
Definition JetRecTool.h:121
ToolHandleArray< IJetConsumer > m_consumers
Definition JetRecTool.h:131
ToolHandle< GenericMonitoringTool > m_monTool
Definition JetRecTool.h:149
const double m_mevtogev
Definition JetRecTool.h:156
std::unique_ptr< xAOD::JetContainer > fillOutputContainer() const
ToolHandleArray< IJetModifier > m_modifiers
Definition JetRecTool.h:130
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
virtual double pt() const
The transverse momentum ( ) of the particle.
Definition Jet_v1.cxx:44
virtual double m() const
The invariant mass of the particle.
Definition Jet_v1.cxx:59
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition Jet_v1.cxx:49
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
Jet_v1 Jet
Definition of the current "jet version".
JetAuxContainer_v1 JetAuxContainer
Definition of the current jet auxiliary container.
JetTrigAuxContainer_v2 JetTrigAuxContainer
Definition of the current jet trigger auxiliary container.

◆ collectPseudoJets()

std::unique_ptr< PseudoJetContainer > JetRecTool::collectPseudoJets ( ) const
private

Definition at line 401 of file JetRecTool.cxx.

401 {
402 // PseudoJetContainer used for jet finding
403
404 auto allPseudoJets = std::make_unique<PseudoJetContainer>();
405
406 ATH_MSG_DEBUG("Fetching pseudojet inputs.");
407
408 for (const auto& pjcontkey : m_psjsin) {
409 SG::ReadHandle<PseudoJetContainer> h_newpsjs( pjcontkey );
410 ATH_MSG_DEBUG("Adding PseudoJetContainers for: " << h_newpsjs.key());
411 if(! h_newpsjs.isValid()) {
412 ATH_MSG_ERROR("Retrieval of PseudoJetContainer "
413 << h_newpsjs.key() << " failed");
414 return nullptr;
415 }
416 allPseudoJets->append(h_newpsjs.get());
417 }
418
419 return allPseudoJets;
420}
SG::ReadHandleKeyArray< PseudoJetContainer > m_psjsin
Definition JetRecTool.h:124

◆ copyJets()

std::unique_ptr< xAOD::JetContainer > JetRecTool::copyJets ( ) const
private

Definition at line 523 of file JetRecTool.cxx.

523 {
524
525 // The new jet collection.
526 auto jets = makeOutputContainer();
527
528 // Retrieve the old jet collection.
529 const auto *jetsIn = getOldJets();
530
531 if(jetsIn == nullptr){
532 ATH_MSG_WARNING("Copying: but input jets not found ");
533 return jets;
534 }
535
536
537 ATH_MSG_DEBUG("Copying " << jetsIn->size() << " jets.");
538
539 for (const Jet* poldjet : *jetsIn) {
540 Jet* pnewjet = new Jet;
541 jets->push_back(pnewjet);
542 *pnewjet = *poldjet;
543 }
544
545 return jets;
546}
std::unique_ptr< xAOD::JetContainer > makeOutputContainer() const
const xAOD::JetContainer * getOldJets() const

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

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

◆ execute()

int JetRecTool::execute ( ) const
overridevirtual

Call build and put jets in event store.

Implements IJetExecuteTool.

Definition at line 311 of file JetRecTool.cxx.

311 {
312 if ( m_initCount == 0 ) {
313 ATH_MSG_WARNING("Execute requested before initialization.");
314 return 1;
315 }
316
317 if ( build() == nullptr ) {
318 ATH_MSG_ERROR("Unable to retrieve container");
319 return 1;
320 }
321 return 0;
322}
virtual const xAOD::JetContainer * build() const override
Retrieve inputs with tools and construct new jet collection.

◆ 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

◆ fillOutputContainer()

std::unique_ptr< xAOD::JetContainer > JetRecTool::fillOutputContainer ( ) const
private

Definition at line 424 of file JetRecTool.cxx.

424 {
425
426 if (!m_finder.empty()) {return findJets();}
427 if (!m_groomer.empty()) {return groomJets();}
428 return copyJets();
429}
std::unique_ptr< xAOD::JetContainer > findJets() const
std::unique_ptr< xAOD::JetContainer > copyJets() const
std::unique_ptr< xAOD::JetContainer > groomJets() const

◆ findJets()

std::unique_ptr< xAOD::JetContainer > JetRecTool::findJets ( ) const
private

Definition at line 479 of file JetRecTool.cxx.

479 {
480
481 ATH_MSG_DEBUG("Finding jets.");
482
483 // The new jet collection.
484 auto jets = makeOutputContainer();
485
486 // PseudoJetContainer used for jet finding
487 auto pseudoJets = collectPseudoJets();
488
489 m_finder->find(*pseudoJets, *jets, m_inputtype);
490
491 return jets;
492}
std::unique_ptr< PseudoJetContainer > collectPseudoJets() const

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

◆ getOldJets()

const xAOD::JetContainer * JetRecTool::getOldJets ( ) const
private

Definition at line 433 of file JetRecTool.cxx.

433 {
434
435 const xAOD::JetContainer* pjetsin{nullptr};
436 auto handle_in = SG::makeHandle (m_incoll);
437 if ( !m_incoll.key().empty() && handle_in.isValid()) {
438 pjetsin = handle_in.cptr();
439 }
440 if ( pjetsin == nullptr && !m_intool.empty() ) {
441 ATH_MSG_DEBUG("Executing input tool.");
442 if ( m_intool->execute() ) {
443 ATH_MSG_WARNING("Input tool execution failed.");
444 }
445 }
446
447 if ( pjetsin == nullptr ) {
448 ATH_MSG_ERROR("Unable to retrieve input jet container: " << m_incoll.key());
449 } else {
450 ATH_MSG_DEBUG("Input collection " << m_incoll.key()
451 << " jet multiplicity is "<< pjetsin->size());
452 }
453 return pjetsin;
454}
size_type size() const noexcept
Returns the number of elements in the collection.
SG::ReadHandleKey< xAOD::JetContainer > m_incoll
Definition JetRecTool.h:122
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
JetContainer_v1 JetContainer
Definition of the current "jet container version".

◆ getProperty()

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

Get one of the tool's properties.

◆ groomJets()

std::unique_ptr< xAOD::JetContainer > JetRecTool::groomJets ( ) const
private

Definition at line 496 of file JetRecTool.cxx.

496 {
497
498 // The new jet collection.
499 auto jets = makeOutputContainer();
500
501 // Retrieve the old jet collection.
502 const auto *jetsIn = getOldJets();
503
504 if(jetsIn == nullptr){
505 ATH_MSG_WARNING("Grooming: but input jets not found ");
506 return jets;
507 }
508
509 ATH_MSG_DEBUG("Grooming " << jetsIn->size() << " jets.");
510
511 // PseudoJetContainer used for jet finding
512 auto pseudoJets = collectPseudoJets();
513
514 for (const auto *const ijet : *jetsIn){ m_groomer->groom(*ijet,
515 *pseudoJets,
516 *jets);}
517
518 return jets;
519}

◆ initialize()

StatusCode JetRecTool::initialize ( void )
overridevirtual

Initialization. Check all tools here.

Reimplemented from asg::AsgTool.

Definition at line 66 of file JetRecTool.cxx.

66 {
67 ATH_MSG_INFO("Initializing JetRecTool " << name() << ".");
69 // Fetch the reconstruction mode.
70 bool needinp = false;
71 bool needout = false;
72 string mode = "pseudojets";
73 if ( !m_outcoll.key().empty() ) {
74 m_outcolls.push_back(m_outcoll.key());
75 if ( ! m_finder.empty() ) {
76 mode = "find";
77 m_find = true;
78 needout = true;
79 if ( m_psjsin.empty() ) {
80 ATH_MSG_ERROR("Jet finding requested with no inputs.");
81 return StatusCode::FAILURE;
82 } else {
83 ATH_CHECK( m_psjsin.initialize() );
84 }
85 } else if ( ! m_groomer.empty() ) {
86 mode = "groom";
87 m_groom = true;
88 needinp = true;
89 needout = true;
90 ATH_CHECK(m_groomer.retrieve());
91 } else {
92 mode = "copy";
93 m_copy = true;
94 needinp = true;
95 needout = true;
96 }
97 }
98 else {
99 m_finder.disable();
100 m_groomer.disable();
101 }
102
103 ATH_CHECK( m_psjsin.initialize() );
104 // Retrieve or create pseudojet retrieval tool.
105 if ( !m_hpjr.empty() ) {
106 if ( m_hpjr.retrieve().isSuccess() ) {
107 m_ppjr = &*m_hpjr;
108 } else {
109 ATH_MSG_ERROR("Unable to retrieve requested pseudojet retriever: " << m_hpjr.name());
110 }
111 } else {
112#ifdef XAOD_STANDALONE
113 m_ppjr = new JetPseudojetRetriever(name()+"_retriever");
114#else
115 m_ppjr = nullptr;
116#endif
117 }
118 ATH_MSG_INFO("Jet reconstruction mode: " << mode);
119 // Check/set the input jet collection name.
120 if ( needinp ) {
121 if ( m_incoll.key().empty() ) {
122 if ( ! m_intool.retrieve() ) {
123 ATH_MSG_ERROR("Input collection must be specified.");
124 return StatusCode::FAILURE;
125 } else {
126 const AsgTool* pasgtool = dynamic_cast<const asg::AsgTool*>(&*m_intool);
127 if ( pasgtool != nullptr ) {
128 const string* pval = pasgtool->getProperty<std::string>("OutputContainer");
129 if ( pval != nullptr ) {
130 m_incoll = *pval;
131 }
132 }
133 if ( m_incoll.key().empty() ) {
134 ATH_MSG_ERROR("Input tool does not have output collection name.");
135 return StatusCode::FAILURE;
136 }
137 }
138 } else {
139 // Input DataHandles
140 ATH_CHECK( m_incoll.initialize() );
141 }
142 m_incolls.push_back(m_incoll.key());
143 }
144 // Check/set the output jet collection name.
145 if ( needout ) {
146 if ( m_outcoll.key().empty() ) {
147 ATH_MSG_ERROR("Output collection must be specified.");
148 return StatusCode::FAILURE;
149 } else {
150 // Output DataHandle
151 ATH_CHECK( m_outcoll.initialize() );
152 }
153 }
154 // Other checks.
155 if ( m_find ) {
156 if ( m_psjsin.empty() ) {
157 ATH_MSG_ERROR("Jet finding requested with no inputs.");
158 return StatusCode::FAILURE;
159 }
160 } else if ( m_groom ) {
161 m_groomer->setPseudojetRetriever(m_ppjr);
162 } else if ( m_copy ) {
163 } else {
164 if ( m_psjsin.empty() ) {
165 ATH_MSG_ERROR("No action requested.");
166 return StatusCode::FAILURE;
167 }
168 }
169 // Parse the pseudojet inputs
170 StatusCode rstat = StatusCode::SUCCESS;
171 string prefix = "--- ";
172 ATH_MSG_INFO(prefix << "JetRecTool " << name() << " has " << m_psjsin.size()
173 << " pseudojet inputs.");
174 for ( size_t ilab(0); ilab<m_psjsin.size(); ++ilab ) {
175 const std::string& pjcontname = m_psjsin[ilab].key();
176 if(pjcontname.size()<9) {
177 ATH_MSG_ERROR("Invalid pseudojet container name " << pjcontname);
178 ATH_MSG_ERROR("This must be of the form \"PseudoJet\"+label");
179 return StatusCode::FAILURE;
180 }
181 std::string label = pjcontname.substr(9);
182 ATH_MSG_INFO(prefix << " " << label << " --> " << pjcontname);
183 // Extract the input type from the first getter.
184 if ( ilab == 0 ) {
185 ATH_MSG_INFO(prefix << "Extracting input type from primary label.");
186 ATH_MSG_INFO(prefix << "Input label: " << label);
188 } else {
189 m_ghostlabs.push_back(label);
190 }
191 }
192 ATH_MSG_INFO(prefix << "Input type: " << m_inputtype);
193 // Fetch the jet modifiers.
194 ATH_MSG_INFO(prefix << "JetRecTool " << name() << " has " << m_modifiers.size()
195 << " jet modifiers.");
196 ATH_CHECK(m_modifiers.retrieve());
197
198 // Fetch the jet consumers.
199 ATH_MSG_INFO(prefix << "JetRecTool " << name() << " has " << m_consumers.size()
200 << " jet consumers.");
201 ATH_CHECK(m_consumers.retrieve());
202
203 ATH_MSG_INFO(prefix << "Input collection names:");
204 for (const auto& name : m_incolls) ATH_MSG_INFO(prefix << " " << name);
205 ATH_MSG_INFO(prefix << "Output collection names:");
206 for (const auto& name : m_outcolls) ATH_MSG_INFO(prefix << " " << name);
207
208#if !defined (GENERATIONBASE) && !defined (XAOD_ANALYSIS)
209 if (!m_monTool.empty()) ATH_CHECK(m_monTool.retrieve());
210#endif
211
212 return rstat;
213}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
std::vector< std::string > m_incolls
Definition JetRecTool.h:141
std::vector< std::string > m_outcolls
Definition JetRecTool.h:142
IJetFinder::NameList m_ghostlabs
Definition JetRecTool.h:140
std::string label(const std::string &format, int i)
Definition label.h:19
::StatusCode StatusCode
StatusCode definition for legacy code.
Type inputType(const std::string &n)

◆ inputContainerNames()

int JetRecTool::inputContainerNames ( std::vector< std::string > & connames)
overridevirtual

Method to return the list of input containers.

The names of required input containers are appended to connames. Returns nonzero for error. Default returns 0 and adds no names.

Reimplemented from IJetExecuteTool.

Definition at line 373 of file JetRecTool.cxx.

373 {
374 if ( m_initCount == 0 ) {
375 ATH_MSG_WARNING("Input container list requested before initialization.");
376 return 1;
377 }
378 connames.insert(connames.end(), m_incolls.begin(), m_incolls.end());
379 return 0;
380}

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

◆ makeOutputContainer()

std::unique_ptr< xAOD::JetContainer > JetRecTool::makeOutputContainer ( ) const
private

Definition at line 458 of file JetRecTool.cxx.

458 {
459 ATH_MSG_DEBUG("Creating output container.");
460
461 auto pjets = std::make_unique<xAOD::JetContainer>();
462
463 if ( !m_outcoll.key().empty() ) {
464 if(m_trigger) {
465 ATH_MSG_DEBUG("Attaching online Aux container.");
466#ifndef GENERATIONBASE
467 pjets->setStore(new xAOD::JetTrigAuxContainer);
468#endif
469 } else {
470 ATH_MSG_DEBUG("Attaching offline Aux container.");
471 pjets->setStore(new xAOD::JetAuxContainer);
472 }
473 }
474 return pjets;
475}

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

◆ outputContainerNames()

int JetRecTool::outputContainerNames ( std::vector< std::string > & connames)
overridevirtual

Method to return the list of output containers.

The names of produced output containers are appended to connames. Returns nonzero for error. Default returns 0 and adds no names.

Reimplemented from IJetExecuteTool.

Definition at line 384 of file JetRecTool.cxx.

384 {
385 if ( m_initCount == 0 ) {
386 ATH_MSG_WARNING("Output container list requested before initialization.");
387 return 1;
388 }
389 connames.insert(connames.end(), m_outcolls.begin(), m_outcolls.end());
390 return 0;
391}

◆ 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 JetRecTool::print ( ) const
overridevirtual

Display the configuration.

Reimplemented from asg::AsgTool.

Definition at line 326 of file JetRecTool.cxx.

326 {
327 ATH_MSG_INFO("Properties for JetRecTool " << name());
328
329 ATH_MSG_INFO(" OutputContainer: " << m_outcoll.key());
330 if ( m_incoll.key().empty() ) ATH_MSG_INFO(" InputContainer is not defined");
331 else ATH_MSG_INFO(" InputContainer: " << m_incoll.key());
332 if ( m_intool.empty() ) {
333 ATH_MSG_INFO(" InputTool is not defined");
334 } else {
335 ATH_MSG_INFO(" InputTool: " << m_intool->name());
336 }
337 if ( !m_psjsin.empty() ) {
338 ATH_MSG_INFO(" InputPseudoJet container count is " << m_psjsin.size());
339 for ( const auto& pjcontkey : m_psjsin ) {
340 ATH_MSG_INFO(" " << pjcontkey.key());
341 }
342 }
343 if ( m_finder.empty() ) {
344 ATH_MSG_INFO(" Jet finder is not defined");
345 } else {
346 ATH_MSG_INFO(" Jet finder: " << m_finder->name());
347 m_finder->print();
348 ATH_MSG_INFO(" Input type: " << m_inputtype);
349 ATH_MSG_INFO(" There are " << m_ghostlabs.size() << " ghost labels:");
350 for ( const string& lab : m_ghostlabs ) ATH_MSG_INFO(" " << lab);
351 }
352 if ( m_groomer.empty() ) {
353 ATH_MSG_INFO(" Jet groomer is not defined");
354 } else {
355 ATH_MSG_INFO(" Jet groomer: " << m_groomer->name());
356 m_groomer->print();
357 }
358 if ( !m_modifiers.empty() ) {
359 ATH_MSG_INFO(" Modifier count is " << m_modifiers.size());
360 for ( ModifierArray::const_iterator imod=m_modifiers.begin();
361 imod!=m_modifiers.end(); ++imod ) {
362 ATH_MSG_INFO(" Modifier " << imod->name());
363 if ( msgLvl(MSG::DEBUG) ) {
364 ToolHandle<IJetModifier> hmod = *imod;
365 hmod->print();
366 }
367 }
368 }
369}
bool msgLvl(const MSG::Level lvl) const

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

◆ setInputJetContainer()

void JetRecTool::setInputJetContainer ( const xAOD::JetContainer * cont)

For trigger usage in grooming mode only : give the input ungroomed jet container.

Definition at line 395 of file JetRecTool.cxx.

395 {
397 }
const xAOD::JetContainer * m_trigInputJetsForGrooming
Definition JetRecTool.h:146

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

ToolHandleArray<IJetConsumer> JetRecTool::m_consumers {this, "JetConsumers", {}}
private

Definition at line 131 of file JetRecTool.h.

131{this, "JetConsumers", {}};

◆ m_copy

bool JetRecTool::m_copy {}
private

Definition at line 138 of file JetRecTool.h.

138{};

◆ 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_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_find

bool JetRecTool::m_find {}
private

Definition at line 136 of file JetRecTool.h.

136{};

◆ m_finder

ToolHandle<IJetFinder> JetRecTool::m_finder
private

Definition at line 128 of file JetRecTool.h.

◆ m_ghostlabs

IJetFinder::NameList JetRecTool::m_ghostlabs
private

Definition at line 140 of file JetRecTool.h.

◆ m_groom

bool JetRecTool::m_groom {}
private

Definition at line 137 of file JetRecTool.h.

137{};

◆ m_groomer

ToolHandle<IJetGroomer> JetRecTool::m_groomer
private

Definition at line 129 of file JetRecTool.h.

◆ m_hpjr

ToolHandle<IJetPseudojetRetriever> JetRecTool::m_hpjr
private

Definition at line 127 of file JetRecTool.h.

◆ m_incoll

SG::ReadHandleKey<xAOD::JetContainer> JetRecTool::m_incoll {this, "InputContainer", ""}
private

Definition at line 122 of file JetRecTool.h.

122{this, "InputContainer", ""};

◆ m_incolls

std::vector<std::string> JetRecTool::m_incolls
private

Definition at line 141 of file JetRecTool.h.

◆ m_initCount

int JetRecTool::m_initCount {}
private

Definition at line 135 of file JetRecTool.h.

135{};

◆ m_inputtype

xAOD::JetInput::Type JetRecTool::m_inputtype
private

Definition at line 139 of file JetRecTool.h.

◆ m_intool

ToolHandle<IJetExecuteTool> JetRecTool::m_intool
private

Definition at line 126 of file JetRecTool.h.

◆ m_mevtogev

const double JetRecTool::m_mevtogev = 0.001
private

Definition at line 156 of file JetRecTool.h.

◆ m_modifiers

ToolHandleArray<IJetModifier> JetRecTool::m_modifiers {this, "JetModifiers", {}}
private

Definition at line 130 of file JetRecTool.h.

130{this, "JetModifiers", {}};

◆ m_monTool

ToolHandle<GenericMonitoringTool> JetRecTool::m_monTool {this,"MonTool","","Monitoring tool"}
private

Definition at line 149 of file JetRecTool.h.

149{this,"MonTool","","Monitoring tool"};

◆ m_outcoll

SG::WriteHandleKey<xAOD::JetContainer> JetRecTool::m_outcoll {this, "OutputContainer", ""}
private

Definition at line 121 of file JetRecTool.h.

121{this, "OutputContainer", ""};

◆ m_outcolls

std::vector<std::string> JetRecTool::m_outcolls
private

Definition at line 142 of file JetRecTool.h.

◆ m_ppjr

const IJetPseudojetRetriever* JetRecTool::m_ppjr {}
private

Definition at line 143 of file JetRecTool.h.

143{};

◆ m_psjsin

SG::ReadHandleKeyArray<PseudoJetContainer> JetRecTool::m_psjsin {this, "InputPseudoJets", {}}
private

Definition at line 124 of file JetRecTool.h.

124{this, "InputPseudoJets", {}};

◆ m_trigger

bool JetRecTool::m_trigger {}
private

Definition at line 132 of file JetRecTool.h.

132{};

◆ m_trigInputJetsForGrooming

const xAOD::JetContainer* JetRecTool::m_trigInputJetsForGrooming {}
private

Definition at line 146 of file JetRecTool.h.

146{}; // used in trigger context only

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