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 const CaloClusterCellLink* cellLinks = (*cluster)->getCellLinks();
106
107 trackCellEta.clear();
108 trackCellPhi.clear();
109 trackCellR.clear();
110 trackCelldEta.clear();
111 trackCelldPhi.clear();
112 trackCelldR.clear();
113 trackCellX.clear();
114 trackCellY.clear();
115 trackCellZ.clear();
116 trackCelldX.clear();
117 trackCelldY.clear();
118 trackCelldZ.clear();
119 trackCellT.clear();
120 trackCellE.clear();
121 trackCellID.clear();
122 trackCellSampling.clear();
123 trackCellQuality.clear();
124 trackCellProvenance.clear();
125 trackCellGain.clear();
126 trackCellEneDiff.clear();
127 trackCellTimeDiff.clear();
128
129 if ( !cellLinks ) {
130 ATH_MSG_ERROR ("Unable to get cell links!");
131 continue;
132 }
133
134 for(const auto cell : *cellLinks) {
135 const CaloDetDescrElement *caloDDE = cell->caloDDE();
136 int sampling = -1;
137 if ( caloDDE ) {
138 sampling = caloDDE->getSampling();
139 trackCellEta.emplace_back(caloDDE->eta());
140 trackCellPhi.emplace_back(caloDDE->phi());
141 trackCellR.emplace_back(caloDDE->r());
142 trackCelldEta.emplace_back(caloDDE->deta());
143 trackCelldPhi.emplace_back(caloDDE->dphi());
144 trackCelldR.emplace_back(caloDDE->dr());
145 trackCellX.emplace_back(caloDDE->x());
146 trackCellY.emplace_back(caloDDE->y());
147 trackCellZ.emplace_back(caloDDE->z());
148 trackCelldX.emplace_back(caloDDE->dx());
149 trackCelldY.emplace_back(caloDDE->dy());
150 trackCelldZ.emplace_back(caloDDE->dz());
151 trackCellT.emplace_back(cell->time());
152 trackCellE.emplace_back(cell->e());
153 Identifier32 IdOfCell = cell->ID().get_identifier32();
154 trackCellID.emplace_back(IdOfCell.get_compact());
155 trackCellSampling.emplace_back(sampling);
156 trackCellQuality.emplace_back(cell->quality());
157 trackCellProvenance.emplace_back(cell->provenance());
158 trackCellGain.emplace_back(cell->gain());
159 if (caloDDE->is_tile()) {
160 trackCellEneDiff.emplace_back(static_cast<const TileCell*>(cell)->eneDiff());
161 trackCellTimeDiff.emplace_back(static_cast<const TileCell*>(cell)->timeDiff());
162 }
163 else {
164 trackCellEneDiff.emplace_back(0);
165 trackCellTimeDiff.emplace_back(0);
166 }
167 } // if ( caloDDE )
168 } // for( cell )
169 } // for( cluster )
170
171 decCellEta(*track) = trackCellEta;
172 decCellPhi(*track) = trackCellPhi;
173 decCellR(*track) = trackCellR;
174 decCelldEta(*track) = trackCelldEta;
175 decCelldPhi(*track) = trackCelldPhi;
176 decCelldR(*track) = trackCelldR;
177 decCellX(*track) = trackCellX;
178 decCellY(*track) = trackCellY;
179 decCellZ(*track) = trackCellZ;
180 decCelldX(*track) = trackCelldX;
181 decCelldY(*track) = trackCelldY;
182 decCelldZ(*track) = trackCelldZ;
183 decCellT(*track) = trackCellT;
184 decCellE(*track) = trackCellE;
185 decCellID(*track) = trackCellID;
186 decCellSampling(*track) = trackCellSampling;
187 decCellQuality(*track) = trackCellQuality;
188 decCellProvenance(*track) = trackCellProvenance;
189 decCellGain(*track) = trackCellGain;
190 decCellEneDiff(*track) = trackCellEneDiff;
191 decCellTimeDiff(*track) = trackCellTimeDiff;
192 }
193
194
195 return StatusCode::SUCCESS;
196 }
197}
#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: