ATLAS Offline Software
Loading...
Searching...
No Matches
xAODMaker::JetCnvTool Class Reference

Implementation for the IJetCnvTool interface. More...

#include <JetCnvTool.h>

Inheritance diagram for xAODMaker::JetCnvTool:
Collaboration diagram for xAODMaker::JetCnvTool:

Public Member Functions

 JetCnvTool (const std::string &type, const std::string &name, const IInterface *parent)
 Regular AlgTool constructor.
virtual StatusCode convert (const JetCollection *aodCont, xAOD::JetContainer *xaodCont, DataLink< xAOD::IParticleContainer > xaodConstitCont=DataLink< xAOD::IParticleContainer >(), bool constitSearch=false) const override
 Function that fills an existing xAOD::MuonRoIContainer.
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

Static Public Member Functions

static const InterfaceID & interfaceID ()
 Gaudi interface definition.

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

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

Private Attributes

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

Implementation for the IJetCnvTool interface.

   This is a simple tool that implements the converter function
   defined in IJetCnvTool.
Author
P-A Delsart

Definition at line 27 of file JetCnvTool.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

◆ JetCnvTool()

xAODMaker::JetCnvTool::JetCnvTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Regular AlgTool constructor.

Definition at line 16 of file JetCnvTool.cxx.

19 : AthAlgTool( type, name, parent ) {
20
21 // Declare the interface(s) provided by the tool:
22 declareInterface< IJetCnvTool >( this );
23 }
AthAlgTool()
Default constructor:

Member Function Documentation

◆ convert()

StatusCode xAODMaker::JetCnvTool::convert ( const JetCollection * aodCont,
xAOD::JetContainer * xaodCont,
DataLink< xAOD::IParticleContainer > xaodConstitCont = DataLink<xAOD::IParticleContainer>(),
bool constitSearch = false ) const
overridevirtual

Function that fills an existing xAOD::MuonRoIContainer.

This is the important function of the tool.

It takes the muon RoI objects from a LVL1_ROI container, and fills an xAOD::MuonRoIContainer with them.

Parameters
aodThe AOD object to take the muon RoIs from
xaodThe xAOD container to fill the RoIs into
Returns
StatusCode::SUCCESS if all went fine, something else if not

Implements xAODMaker::IJetCnvTool.

Definition at line 34 of file JetCnvTool.cxx.

38 {
39
40
43
44 std::vector< std::string > momentKeys ;
45
46 if( it != itE ) {
47 momentKeys= (*it)->getMomentKeys();
48
49 if( xaodConstitCont.isDefault() &&
50 (*it)->begin() != (*it)->end() )
51 {
52 // try to retrieve its name from SG and the original jet
53
54 // this doesn't work : getConstituents() is protected
55 // std::string key = (*it)->navigableBase().getConstituents()[0].key();
56 // StatusCode sc = evtStore()->retrieve(xaodConstitCont, key);
57 // if(sc.isFailure() ) ATH_MSG_DEBUG("Could not retrieve xaod constiuents with key "<< key );
58
59 SG::DataProxy* proxy = evtStore()->proxy( (*it)->getContainer( (*it)->begin() ) );
60 if(proxy) {
61 xaodConstitCont.toIdentifiedObject (proxy->name());
62 if( !xaodConstitCont ) ATH_MSG_DEBUG("Could not retrieve xaod constiuents with key "<< proxy->name() );
63 }
64 }
65 }
66
67
68 for( ; it!= itE; ++it){
69 const Jet * jet = *it;
70 Jet::const_iterator cit = jet->begin();
71 Jet::const_iterator citE = jet->end();
72
73 xAOD::Jet* xjet = new xAOD::Jet();
74 xaodCont->push_back( xjet );
75
76 xjet->setJetP4( xAOD::JetFourMom_t(jet->pt(), jet->eta(), jet->phi(), jet->m() ) );
77
78 // convert constituents if we have a valid xaod constituent container.
79 // If constitSearch is false, this assumes the ordering
80 // in aod and xaod containers are the same !
81 if(xaodConstitCont) {
82 for( ; cit!= citE; ++cit){
83 if (constitSearch) {
84 double min_dr2 = 0.1 * 0.1;
85 int iconstit = -1;
86 int ip = 0;
87 for (const xAOD::IParticle* p : *xaodConstitCont) {
88 double deta = p->eta() - (*cit)->eta();
89 double dphi = TVector2::Phi_mpi_pi (p->phi() - (*cit)->phi());
90 double dr2 = deta*deta + dphi*dphi;
91 if (dr2 < min_dr2) {
92 min_dr2 = dr2;
93 iconstit = ip;
94 }
95 ++ip;
96 }
97 if (iconstit >= 0)
98 xjet->addConstituent
99 (ElementLink<xAOD::IParticleContainer> (xaodConstitCont.key(), iconstit));
100 }
101 else {
102 size_t index;
103 if( jet->getIndex( cit , index) )
104 xjet->addConstituent
105 (ElementLink<xAOD::IParticleContainer> (xaodConstitCont.key(), index));
106 }
107 }
108 }
109
110 for(size_t i=0;i<momentKeys.size(); i++){
111 xjet->setAttribute<float>( momentKeys[i], jet->getMoment( momentKeys[i]) );
112 }
113 ATH_MSG_DEBUG( "Converted " << jet << " into "<< xjet << " pt="<< xjet->pt()<< " numConst="<< xjet->numConstituents() );
114
117 xjet->setJetP4( s, xAOD::JetFourMom_t( jet->pt(aod_s), jet->eta(aod_s) , jet->phi(aod_s), jet->m(aod_s) ) );
120 xjet->setJetP4( s, xAOD::JetFourMom_t( jet->pt(aod_s), jet->eta(aod_s) , jet->phi(aod_s), jet->m(aod_s) ) );
121
122 P4SignalState::State aod_constit_s = jet->constituentSignalState() ;
123 xjet->setConstituentsSignalState( (xAOD::JetConstitScale) aod_constit_s );
124
125 // // Track assoc if any :
126 // const Analysis::TrackAssociation * trackA = jet-> getAssociation<Analysis::TrackAssociation>("TrackAssoc");
127 // if (trackA) {
128 // Analysis::TrackAssociation::object_iter trk_it = trackA->begin();
129 // Analysis::TrackAssociation::object_iter trk_itE= trackA->end();
130 // size_t trk_index;
131 // for( ; trk_it != trk_itE ; ++trk_it){
132 // if( trackA->getIndex( trk_it, trk_index) )
133 // if( (*it)->pt() > m_trackMinPt && (m_jetvtxtrkHelper->trackInfo(*it).selected() ) )
134 // preSelTracks.push_back(*it);
135
136 }
137
138 return StatusCode::SUCCESS;
139 }
#define ATH_MSG_DEBUG(x)
Jet_v1 Jet
Definition of the current "jet version".
ServiceHandle< StoreGateSvc > & evtStore()
bool isDefault() const
Test to see if we're in the default state.
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
signalstate_t constituentSignalState() const
Get the current Signal state of the jet constituents.
bool getIndex(const constituent_t *pConst, index_t &ind) const
Retrieve index of object in container.
shape_t getMoment(const mkey_t &shapeName, bool addIfMissing=false) const
Alias for getShape.
navigable_t::object_iter const_iterator
const_iterator begin() const
Begin iterator for constituent store.
const_iterator end() const
End iterator for constituent store.
virtual double eta() const
pseudo rapidity
virtual double phi() const
phi in [-pi,pi[
virtual double m() const
mass
virtual double pt() const
transverse momentum
void setAttribute(const std::string &name, const T &v)
void addConstituent(const ElementLink< IParticleContainer > &link, float weight=1.0)
Add a constituent directly in the ElementLink format.
Definition Jet_v1.cxx:111
size_t numConstituents() const
Number of constituents in this jets (this is valid even when reading a file where the constituents ha...
Definition Jet_v1.cxx:153
void setJetP4(const JetFourMom_t &p4)
Definition Jet_v1.cxx:171
void setConstituentsSignalState(JetConstitScale t)
Set the state at which constituents were when this jet was found. This function is called by jet buil...
Definition Jet_v1.cxx:141
virtual double pt() const
The transverse momentum ( ) of the particle.
Definition Jet_v1.cxx:44
str index
Definition DeMoScan.py:362
Jet_v1 Jet
Definition of the current "jet version".
JetScale
Definition JetTypes.h:26
@ JetEMScaleMomentum
Definition JetTypes.h:28
@ JetConstitScaleMomentum
Definition JetTypes.h:29
JetConstitScale
Definition JetTypes.h:20
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition JetTypes.h:17

◆ 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

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

◆ interfaceID()

const InterfaceID & xAODMaker::IJetCnvTool::interfaceID ( )
inlinestaticinherited

Gaudi interface definition.

Definition at line 48 of file IJetCnvTool.h.

48 {
49 return IID_IJetCnvTool;
50 }
static const InterfaceID IID_IJetCnvTool("xAODMaker::IJetCnvTool", 1, 0)
The interface provided by IJetCnvTool.

◆ msg()

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

Definition at line 24 of file AthCommonMsg.h.

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

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

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