ATLAS Offline Software
Loading...
Searching...
No Matches
TrackParticleCellAssociationAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
10
11
13
15{
17
21 ATH_CHECK(m_clusterCellLinkName.initialize());
22 ATH_CHECK(m_trkLinkKey.initialize());
23 return StatusCode::SUCCESS;
24}
25
26StatusCode TrackParticleCellAssociationAlg::execute(const EventContext& ctx) const
27{
28 // get track particles
30
31 // Create the xAOD container and its auxiliary store:
34
35
37 ATH_CHECK(xaoda.record (std::make_unique<xAOD::TrackParticleClusterAssociationContainer>(),
38 std::make_unique<xAOD::TrackParticleClusterAssociationAuxContainer>()));
39
40
41
42 unsigned int ntracks = 0;
43 for( unsigned int i=0;i<trackParticles->size();++i ){
44
45 // slect track
46 const xAOD::TrackParticle* tp = (*trackParticles)[i];
47 if( tp->pt() < m_ptCut ) continue;
48
49 // get ParticleCellAssociation
50 ATH_MSG_DEBUG(" Selected track: pt " << tp->pt() << " eta " << tp->eta() << " phi " << tp->phi() );
51 std::unique_ptr<const Rec::ParticleCellAssociation> association
52 =m_caloCellAssociationTool->particleCellAssociation(*tp,0.1);
53 if(!association){
54 ATH_MSG_DEBUG("failed to obtain the ParticleCellAssociation");
55 continue;
56 }
57
58 // require container as it should be there
59 if( !association->container() ){
60 ATH_MSG_WARNING("Failed to obtain CaloCellContainer from ParticleCellAssociation");
61 continue;
62 }
63
64 // create cell from ParticleCellAssociation
66 *association->container(),
67 *clusColl );
68 if( !cluster ){
69 ATH_MSG_WARNING("Failed to create cluster from ParticleCellAssociation");
70 continue;
71 }else{
72 ATH_MSG_DEBUG(" New cluster: eta " << cluster->eta() << " phi " << cluster->phi() << " cells " << cluster->size() << " nclusters " << clusColl->size() );
73 }
74
75 // create element links
77 ElementLink< xAOD::CaloClusterContainer > clusterLink(m_clusterContainerName.key(),clusColl->size()-1);
78
79 // if valid create TrackParticleClusterAssociation
80 if( trackLink.isValid() && clusterLink.isValid() ){
82 xaoda->push_back(trackAssociation);
83 trackAssociation->setTrackParticleLink( trackLink );
84 std::vector< ElementLink< xAOD::CaloClusterContainer > > caloClusterLinks;
85 caloClusterLinks.push_back( clusterLink );
86 trackAssociation->setCaloClusterLinks(caloClusterLinks);
87 ATH_MSG_DEBUG("added association");
88 ++ntracks;
89 }else{
90 if( !trackLink.isValid() ) ATH_MSG_WARNING("Failed to create track ElementLink ");
91 if( !clusterLink.isValid() ) ATH_MSG_WARNING("Failed to create cluster ElementLink ");
92 }
93 }
94
95 ATH_MSG_DEBUG(" Total number of selected tracks: " << ntracks );
96
99 clusColl.ptr()));
100 return StatusCode::SUCCESS;
101}
102
103
105{
106 return StatusCode::SUCCESS;
107}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static StatusCode AddContainerWriteHandle(SG::WriteHandle< xAOD::CaloClusterContainer > &clusColl)
Creates a new xAOD::CaloClusterContainer in the given WriteHandle + CaloClusterAuxContainer and recor...
static StatusCode finalizeClusters(SG::WriteHandle< CaloClusterCellLinkContainer > &h, xAOD::CaloClusterContainer *pClusterColl)
Finalize clusters (move CaloClusterCellLink to a separate container).
static xAOD::CaloCluster * crossedCells(const Rec::ParticleCellAssociation &association, const CaloCellContainer &cellContainer, xAOD::CaloClusterContainer &clusterContainer)
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
StatusCode execute(const EventContext &ctx) const override
SG::WriteHandleKey< xAOD::TrackParticleClusterAssociationContainer > m_associationContainerName
SG::WriteHandleKey< xAOD::CaloClusterContainer > m_clusterContainerName
SG::WriteHandleKey< CaloClusterCellLinkContainer > m_clusterCellLinkName
ToolHandle< Rec::IParticleCaloCellAssociationTool > m_caloCellAssociationTool
SG::ReadDecorHandleKey< xAOD::TrackParticleContainer > m_trkLinkKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackParticleCollectionName
virtual double eta() const
The pseudorapidity ( ) of the particle.
size_t size() const
size method (forwarded from CaloClusterCellLink obj)
virtual double phi() const
The azimuthal angle ( ) of the particle.
void setTrackParticleLink(const ElementLink< TrackParticleContainer > &trackParticleLink)
Sets.
void setCaloClusterLinks(const std::vector< ElementLink< CaloClusterContainer > > &caloClusterLinks)
Sets.
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .).
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
TrackParticleClusterAssociation_v1 TrackParticleClusterAssociation
Reference the current persistent version:
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
TrackParticle_v1 TrackParticle
Reference the current persistent version: