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

#include <TrackCollectionCnvTool.h>

Inheritance diagram for xAODMaker::TrackCollectionCnvTool:
Collaboration diagram for xAODMaker::TrackCollectionCnvTool:

Public Member Functions

 TrackCollectionCnvTool (const std::string &type, const std::string &name, const IInterface *parent)
 Regular AlgTool constructor.
virtual StatusCode initialize () override
 Function initialising the tool.
virtual StatusCode convert (const TrackCollection *aod, xAOD::TrackParticleContainer *xaod, const xAOD::Vertex *vtx=nullptr) const override
 Function that fills an existing xAOD::TrackParticleContainer.
virtual StatusCode convertAndAugment (const TrackCollection *aod, xAOD::TrackParticleContainer *xaod, const ObservedTrackMap *trk_map, const xAOD::Vertex *vtx=nullptr) const override
 Function that fills an existing xAOD::TrackParticleContainer and augments track particles.
virtual StatusCode setParticleCreatorTool (ToolHandle< Trk::ITrackParticleCreatorTool > *tool) override
 allow other algorithms to pass the tool in order to preserve initialisation
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

xAOD::TrackParticlecreateParticle (xAOD::TrackParticleContainer &xaod, const TrackCollection &container, const Trk::Track &tp, const xAOD::Vertex *vtx) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

ToolHandle< Trk::ITrackParticleCreatorToolm_particleCreator
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 27 of file TrackCollectionCnvTool.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

◆ TrackCollectionCnvTool()

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

Regular AlgTool constructor.

Definition at line 16 of file TrackCollectionCnvTool.cxx.

19 : AthAlgTool( type, name, parent ),
20 m_particleCreator("Trk::TrackParticleCreatorTool/TrackParticleCreatorTool")
21 {
22
23 // Declare the interface(s) provided by the tool:
24 declareInterface< ITrackCollectionCnvTool >( this );
25 declareProperty("TrackParticleCreator", m_particleCreator, "creator of xAOD::TrackParticles");
26 }
AthAlgTool()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ToolHandle< Trk::ITrackParticleCreatorTool > m_particleCreator

Member Function Documentation

◆ convert()

StatusCode xAODMaker::TrackCollectionCnvTool::convert ( const TrackCollection * aod,
xAOD::TrackParticleContainer * xaod,
const xAOD::Vertex * vtx = nullptr ) const
overridevirtual

Function that fills an existing xAOD::TrackParticleContainer.

Implements xAODMaker::ITrackCollectionCnvTool.

Definition at line 36 of file TrackCollectionCnvTool.cxx.

37 {
38
39 ATH_MSG_DEBUG( "Sizes of containers before conversion: aod, xaod: " << aod->size() << ", " << xaod->size() );
40
43
44 for( ;itr!=end;++itr ) {
45 // Create the xAOD object:
46 if (!(*itr)) {
47 ATH_MSG_WARNING("Empty element in container!");
48 continue;
49 }
50 xAOD::TrackParticle* particle = createParticle(*xaod, *aod, **itr, vtx);
51
52 if (!particle) {
53 ATH_MSG_WARNING("Failed to create a TrackParticle");
54 continue;
55 }
56 }
57
58 ATH_MSG_DEBUG( "Sizes of containers after conversion: aod, xaod: " << aod->size() << ", " << xaod->size() );
59
60 return StatusCode::SUCCESS;
61 }
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
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.
size_type size() const noexcept
Returns the number of elements in the collection.
xAOD::TrackParticle * createParticle(xAOD::TrackParticleContainer &xaod, const TrackCollection &container, const Trk::Track &tp, const xAOD::Vertex *vtx) const
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
TrackParticle_v1 TrackParticle
Reference the current persistent version:

◆ convertAndAugment()

StatusCode xAODMaker::TrackCollectionCnvTool::convertAndAugment ( const TrackCollection * aod,
xAOD::TrackParticleContainer * xaod,
const ObservedTrackMap * trk_map,
const xAOD::Vertex * vtx = nullptr ) const
overridevirtual

Function that fills an existing xAOD::TrackParticleContainer and augments track particles.

Implements xAODMaker::ITrackCollectionCnvTool.

Definition at line 63 of file TrackCollectionCnvTool.cxx.

64 {
65
66 ATH_MSG_DEBUG( "convertAndAugment: Sizes of containers before conversion: aod, xaod: " << aod->size() << ", " << xaod->size() );
67 ATH_MSG_DEBUG( "convertAndAugment: Size of track map: " << trk_map->size() );
68
71 ObservedTrackMap::const_iterator itrMap = trk_map->begin();
72
73 // Check size of track collection matches size of observed tracks map
74 if(aod->size() != trk_map->size()){
75 ATH_MSG_ERROR("convertAndAugment: Number of tracks different in collection to convert vs. observed tracks map: "<<aod->size()<<" vs. "<<trk_map->size());
76 return StatusCode::FAILURE;
77 }
78
79 for( ;itr!=end;++itr ) {
80 // Create the xAOD object:
81 if (!(*itr)) {
82 ATH_MSG_WARNING("convertAndAugment: Empty element in container!");
83 continue;
84 }
85 xAOD::TrackParticle* particle = createParticle(*xaod, *aod, **itr, vtx);
86 if(!particle){
87 ATH_MSG_WARNING("convertAndAugment: Failed to create a TrackParticle");
88 ++itrMap;
89 continue;
90 }
91 // Augment xAOD object with information from track map
92 static const SG::Decorator<long int> IdDec ("Id");
93 IdDec (*particle) = (*itrMap).first;
94
95#define DECORATE2(NAME, SEL, TYPE) \
96 static const SG::Decorator<TYPE> NAME##Dec (#NAME); \
97 NAME##Dec(*particle) = std::get<xAOD::ObserverToolIndex::SEL>((*itrMap).second)
98#define DECORATE(NAME, TYPE) DECORATE2(NAME, NAME, TYPE)
99 DECORATE(score, double);
100 DECORATE(rejectStep, int);
101 DECORATE(rejectReason, int);
102 DECORATE(parentId, long int);
103 DECORATE(numPixelHoles, int);
104 DECORATE(numSCTHoles, int);
105 DECORATE(numSplitSharedPixel, int);
106 DECORATE(numSplitSharedSCT, int);
107 DECORATE(numSharedOrSplit, int);
108 DECORATE(numSharedOrSplitPixels, int);
109 DECORATE(numShared, int);
110 DECORATE(isPatternTrack, int);
111 DECORATE(totalSiHits, int);
112 DECORATE(inROI, int);
113 DECORATE2(thishasblayer, hasIBLHit, int);
114 DECORATE2(hassharedblayer, hasSharedIBLHit, int);
115 DECORATE2(hassharedpixel, hasSharedPixel, int);
116 DECORATE2(firstisshared, firstPixIsShared, int);
117 DECORATE(numPixelDeadSensor, int);
118 DECORATE(numSCTDeadSensor, int);
119 DECORATE(numPixelHits, int);
120 DECORATE(numSCTHits, int);
121 DECORATE(numUnused, int);
122 DECORATE(numTRT_Unused, int);
123 DECORATE(numSCT_Unused, int);
124 DECORATE(numPseudo, int);
125 DECORATE(averageSplit1, int);
126 DECORATE(averageSplit2, int);
127 DECORATE(numWeightedShared, int);
128#undef DECORATE
129#undef DECORATE2
130
131 const std::vector<xAOD::RejectionStep>& v_rejectStep =
132 std::get<xAOD::ObserverToolIndex::rejectStep_full>((*itrMap).second);
133 const std::vector<xAOD::RejectionReason>& v_rejectReason =
134 std::get<xAOD::ObserverToolIndex::rejectReason_full>((*itrMap).second);
135 static const SG::Decorator<std::vector<int> > rejectStep_fullDec ("rejectStep_full");
136 static const SG::Decorator<std::vector<int> > rejectReason_fullDec ("rejectReason_full");
137 rejectStep_fullDec(*particle).assign (v_rejectStep.begin(), v_rejectStep.end());
138 rejectReason_fullDec(*particle).assign (v_rejectReason.begin(), v_rejectReason.end());
139 ATH_MSG_DEBUG("convertAndAugment: Augmenting TrackParticle with id "
140 << IdDec(*particle) << " and rejectReason "
141 << rejectReasonDec(*particle)
142 << " (has chi2 = " << particle->chiSquared() << ")");
143 ++itrMap;
144 }
146 "convertAndAugment: Sizes of containers after conversion: aod, xaod: "
147 << aod->size() << ", " << xaod->size());
148 return StatusCode::SUCCESS;
149 }
#define ATH_MSG_ERROR(x)
#define DECORATE(NAME, TYPE)
#define DECORATE2(NAME, SEL, TYPE)

◆ createParticle()

xAOD::TrackParticle * xAODMaker::TrackCollectionCnvTool::createParticle ( xAOD::TrackParticleContainer & xaod,
const TrackCollection & container,
const Trk::Track & tp,
const xAOD::Vertex * vtx ) const
inlineprivate

Definition at line 151 of file TrackCollectionCnvTool.cxx.

154 {
155 // create the xAOD::TrackParticle, the pointer is added to the container in the function
156 ElementLink<TrackCollection> trackLink( &tp, container );
157 return m_particleCreator->createParticle( trackLink, &xaod , vtx);
158 //no! return m_particleCreator->createParticle( tp, &xaod );
159 }

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

◆ 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

◆ initialize()

StatusCode xAODMaker::TrackCollectionCnvTool::initialize ( )
overridevirtual

Function initialising the tool.

Definition at line 28 of file TrackCollectionCnvTool.cxx.

28 {
29 // Greet the user:
30 ATH_MSG_INFO( "Initializing TrackCollectionCnvTool with " << m_particleCreator.name() );
31 ATH_CHECK( m_particleCreator.retrieve() );
32
33 return StatusCode::SUCCESS;
34 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)

◆ 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::ITrackCollectionCnvTool::interfaceID ( )
inlinestaticinherited

Gaudi interface definition.

Definition at line 47 of file ITrackCollectionCnvTool.h.

47 {
49 }
static const InterfaceID IID_ITrackCollectionCnvTool("xAODMaker::ITrackCollectionCnvTool", 1, 0)
The interface provided by ITrackCollectionCnvTool.

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

◆ setParticleCreatorTool()

StatusCode xAODMaker::TrackCollectionCnvTool::setParticleCreatorTool ( ToolHandle< Trk::ITrackParticleCreatorTool > * tool)
overridevirtual

allow other algorithms to pass the tool in order to preserve initialisation

Implements xAODMaker::ITrackCollectionCnvTool.

Definition at line 161 of file TrackCollectionCnvTool.cxx.

162 {
163 ATH_MSG_DEBUG( "In setParticleCreatorTool" );
165
166 return StatusCode::SUCCESS;
167 }

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

ToolHandle<Trk::ITrackParticleCreatorTool> xAODMaker::TrackCollectionCnvTool::m_particleCreator
private

Definition at line 50 of file TrackCollectionCnvTool.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: