ATLAS Offline Software
Loading...
Searching...
No Matches
TrackParticleCaloCellDecorator.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5/* TrackParticleCaloCellDecorator.cxx */
6
9#include <vector>
10#include <string>
11#include "TileEvent/TileCell.h"
12
13namespace DerivationFramework {
14
16
18 ATH_CHECK(m_trackContainerKey.initialize());
19
20 ATH_CHECK(m_decCellEtaKey.initialize());
21 ATH_CHECK(m_decCellPhiKey.initialize());
22 ATH_CHECK(m_decCellRKey.initialize());
23 ATH_CHECK(m_decCelldEtaKey.initialize());
24 ATH_CHECK(m_decCelldPhiKey.initialize());
25 ATH_CHECK(m_decCelldRKey.initialize());
26 ATH_CHECK(m_decCellXKey.initialize());
27 ATH_CHECK(m_decCellYKey.initialize());
28 ATH_CHECK(m_decCellZKey.initialize());
29 ATH_CHECK(m_decCelldXKey.initialize());
30 ATH_CHECK(m_decCelldYKey.initialize());
31 ATH_CHECK(m_decCelldZKey.initialize());
32 ATH_CHECK(m_decCellTKey.initialize());
33 ATH_CHECK(m_decCellEKey.initialize());
34 ATH_CHECK(m_decCellIDKey.initialize());
35 ATH_CHECK(m_decCellSamplingKey.initialize());
36 ATH_CHECK(m_decCellQualityKey.initialize());
38 ATH_CHECK(m_decCellGainKey.initialize());
39 ATH_CHECK(m_decCellEneDiffKey.initialize());
40 ATH_CHECK(m_decCellTimeDiffKey.initialize());
41
42 return StatusCode::SUCCESS;
43 }
44
45
46 StatusCode TrackParticleCaloCellDecorator::addBranches(const EventContext& ctx) const {
47
49 ATH_CHECK( clusterAssociations.isValid() );
50
72
73 for(const auto clusterAssociation : *clusterAssociations) {
74 std::vector<float> trackCellEta(0, 0.);
75 std::vector<float> trackCellPhi(0, 0.);
76 std::vector<float> trackCellR(0, 0.);
77 std::vector<float> trackCelldEta(0, 0.);
78 std::vector<float> trackCelldPhi(0, 0.);
79 std::vector<float> trackCelldR(0, 0.);
80 std::vector<float> trackCellX(0, 0.);
81 std::vector<float> trackCellY(0, 0.);
82 std::vector<float> trackCellZ(0, 0.);
83 std::vector<float> trackCelldX(0, 0.);
84 std::vector<float> trackCelldY(0, 0.);
85 std::vector<float> trackCelldZ(0, 0.);
86 std::vector<float> trackCellT(0, 0.);
87 std::vector<float> trackCellE(0, 0.);
88 std::vector<unsigned int> trackCellID(0, 0);
89 std::vector<int> trackCellSampling(0, 0);
90 std::vector<int> trackCellQuality(0, 0);
91 std::vector<int> trackCellProvenance(0, 0);
92 std::vector<int> trackCellGain(0, 0);
93 std::vector<float> trackCellEneDiff(0, 0);
94 std::vector<float> trackCellTimeDiff(0, 0);
95
96 const xAOD::TrackParticle* track = nullptr;
97 if (clusterAssociation->trackParticleLink().isValid()) {
98 track = *(clusterAssociation->trackParticleLink());
99 } else {
100 ATH_MSG_DEBUG ("trackParticleLink is not valid! " );
101 continue;
102 }
103
104 for (const auto& cluster : clusterAssociation->caloClusterLinks()) {
105 if ( !cluster.isValid() ) {
106 ATH_MSG_DEBUG("Invalid caloClusterLink on TrackParticleClusterAssociation - skipping");
107 continue;
108 }
109 const CaloClusterCellLink* cellLinks = (*cluster)->getCellLinks();
110
111 trackCellEta.clear();
112 trackCellPhi.clear();
113 trackCellR.clear();
114 trackCelldEta.clear();
115 trackCelldPhi.clear();
116 trackCelldR.clear();
117 trackCellX.clear();
118 trackCellY.clear();
119 trackCellZ.clear();
120 trackCelldX.clear();
121 trackCelldY.clear();
122 trackCelldZ.clear();
123 trackCellT.clear();
124 trackCellE.clear();
125 trackCellID.clear();
126 trackCellSampling.clear();
127 trackCellQuality.clear();
128 trackCellProvenance.clear();
129 trackCellGain.clear();
130 trackCellEneDiff.clear();
131 trackCellTimeDiff.clear();
132
133 if ( !cellLinks ) {
134 ATH_MSG_ERROR ("Unable to get cell links!");
135 continue;
136 }
137
138 for(const auto cell : *cellLinks) {
139 const CaloDetDescrElement *caloDDE = cell->caloDDE();
140 int sampling = -1;
141 if ( caloDDE ) {
142 sampling = caloDDE->getSampling();
143 trackCellEta.emplace_back(caloDDE->eta());
144 trackCellPhi.emplace_back(caloDDE->phi());
145 trackCellR.emplace_back(caloDDE->r());
146 trackCelldEta.emplace_back(caloDDE->deta());
147 trackCelldPhi.emplace_back(caloDDE->dphi());
148 trackCelldR.emplace_back(caloDDE->dr());
149 trackCellX.emplace_back(caloDDE->x());
150 trackCellY.emplace_back(caloDDE->y());
151 trackCellZ.emplace_back(caloDDE->z());
152 trackCelldX.emplace_back(caloDDE->dx());
153 trackCelldY.emplace_back(caloDDE->dy());
154 trackCelldZ.emplace_back(caloDDE->dz());
155 trackCellT.emplace_back(cell->time());
156 trackCellE.emplace_back(cell->e());
157 Identifier32 IdOfCell = cell->ID().get_identifier32();
158 trackCellID.emplace_back(IdOfCell.get_compact());
159 trackCellSampling.emplace_back(sampling);
160 trackCellQuality.emplace_back(cell->quality());
161 trackCellProvenance.emplace_back(cell->provenance());
162 trackCellGain.emplace_back(cell->gain());
163 if (caloDDE->is_tile()) {
164 trackCellEneDiff.emplace_back(static_cast<const TileCell*>(cell)->eneDiff());
165 trackCellTimeDiff.emplace_back(static_cast<const TileCell*>(cell)->timeDiff());
166 }
167 else {
168 trackCellEneDiff.emplace_back(0);
169 trackCellTimeDiff.emplace_back(0);
170 }
171 } // if ( caloDDE )
172 } // for( cell )
173 } // for( cluster )
174
175 decCellEta(*track) = trackCellEta;
176 decCellPhi(*track) = trackCellPhi;
177 decCellR(*track) = trackCellR;
178 decCelldEta(*track) = trackCelldEta;
179 decCelldPhi(*track) = trackCelldPhi;
180 decCelldR(*track) = trackCelldR;
181 decCellX(*track) = trackCellX;
182 decCellY(*track) = trackCellY;
183 decCellZ(*track) = trackCellZ;
184 decCelldX(*track) = trackCelldX;
185 decCelldY(*track) = trackCelldY;
186 decCelldZ(*track) = trackCelldZ;
187 decCellT(*track) = trackCellT;
188 decCellE(*track) = trackCellE;
189 decCellID(*track) = trackCellID;
190 decCellSampling(*track) = trackCellSampling;
191 decCellQuality(*track) = trackCellQuality;
192 decCellProvenance(*track) = trackCellProvenance;
193 decCellGain(*track) = trackCellGain;
194 decCellEneDiff(*track) = trackCellEneDiff;
195 decCellTimeDiff(*track) = trackCellTimeDiff;
196 }
197
198
199 return StatusCode::SUCCESS;
200 }
201}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
Handle class for adding a decoration to an object.
This class groups all DetDescr information related to a CaloCell.
CaloCell_ID::CaloSample getSampling() const
cell sampling
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellQualityKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellXKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCelldYKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellZKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCelldPhiKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCelldZKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellTKey
SG::ReadHandleKey< xAOD::TrackParticleClusterAssociationContainer > m_trackContainerKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellEtaKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellEneDiffKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellGainKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCelldEtaKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellPhiKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCelldRKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellSamplingKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCelldXKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellIDKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackParticleContainerKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellEKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellTimeDiffKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellProvenanceKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellRKey
virtual StatusCode addBranches(const EventContext &ctx) const override final
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellYKey
value_type get_compact() const
Get the compact id.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Handle class for adding a decoration to an object.
THE reconstruction tool.
TrackParticle_v1 TrackParticle
Reference the current persistent version: