ATLAS Offline Software
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 
13 namespace DerivationFramework {
14 
16 
18  ATH_CHECK(m_trackContainerKey.initialize());
19 
41 
42  return StatusCode::SUCCESS;
43  }
44 
45 
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 }
CaloDetDescrElement::deta
float deta() const
cell deta
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:356
TileCell
Definition: TileCell.h:57
DerivationFramework::TrackParticleCaloCellDecorator::m_trackContainerKey
SG::ReadHandleKey< xAOD::TrackParticleClusterAssociationContainer > m_trackContainerKey
Definition: TrackParticleCaloCellDecorator.h:33
Identifier32
Definition: Identifier32.h:25
DerivationFramework::TrackParticleCaloCellDecorator::m_decCellGainKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellGainKey
Definition: TrackParticleCaloCellDecorator.h:72
DerivationFramework::TrackParticleCaloCellDecorator::m_decCelldPhiKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCelldPhiKey
Definition: TrackParticleCaloCellDecorator.h:44
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
DerivationFramework::TrackParticleCaloCellDecorator::m_decCellTimeDiffKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellTimeDiffKey
Definition: TrackParticleCaloCellDecorator.h:76
CaloDetDescrElement::y
float y() const
cell y
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:365
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
DerivationFramework::TrackParticleCaloCellDecorator::m_decCelldEtaKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCelldEtaKey
Definition: TrackParticleCaloCellDecorator.h:42
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
DerivationFramework::TrackParticleCaloCellDecorator::m_decCellZKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellZKey
Definition: TrackParticleCaloCellDecorator.h:52
DerivationFramework::TrackParticleCaloCellDecorator::m_decCellYKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellYKey
Definition: TrackParticleCaloCellDecorator.h:50
CaloDetDescrElement::dr
float dr() const
cell dr
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:360
DerivationFramework::TrackParticleCaloCellDecorator::m_decCelldXKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCelldXKey
Definition: TrackParticleCaloCellDecorator.h:54
Identifier32::get_compact
value_type get_compact() const
Get the compact id.
Definition: Identifier32.h:44
DerivationFramework::TrackParticleCaloCellDecorator::m_decCellEtaKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellEtaKey
Definition: TrackParticleCaloCellDecorator.h:36
TrackParticleCaloCellDecorator.h
CaloDetDescrElement::dz
float dz() const
cell dz
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:379
DerivationFramework::TrackParticleCaloCellDecorator::m_decCelldRKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCelldRKey
Definition: TrackParticleCaloCellDecorator.h:46
DerivationFramework::TrackParticleCaloCellDecorator::initialize
virtual StatusCode initialize() override final
Definition: TrackParticleCaloCellDecorator.cxx:15
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
TileCell.h
WriteDecorHandle.h
Handle class for adding a decoration to an object.
DerivationFramework::TrackParticleCaloCellDecorator::m_decCelldZKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCelldZKey
Definition: TrackParticleCaloCellDecorator.h:58
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework::TrackParticleCaloCellDecorator::m_decCellXKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellXKey
Definition: TrackParticleCaloCellDecorator.h:48
DerivationFramework::TrackParticleCaloCellDecorator::m_decCellPhiKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellPhiKey
Definition: TrackParticleCaloCellDecorator.h:38
DerivationFramework::TrackParticleCaloCellDecorator::m_trackParticleContainerKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackParticleContainerKey
Definition: TrackParticleCaloCellDecorator.h:30
DerivationFramework::TrackParticleCaloCellDecorator::m_decCellIDKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellIDKey
Definition: TrackParticleCaloCellDecorator.h:64
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
CaloDetDescrElement::is_tile
bool is_tile() const
cell belongs to Tile
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:442
DerivationFramework::TrackParticleCaloCellDecorator::m_decCelldYKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCelldYKey
Definition: TrackParticleCaloCellDecorator.h:56
DerivationFramework::TrackParticleCaloCellDecorator::m_decCellTKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellTKey
Definition: TrackParticleCaloCellDecorator.h:60
DerivationFramework::TrackParticleCaloCellDecorator::m_decCellSamplingKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellSamplingKey
Definition: TrackParticleCaloCellDecorator.h:66
DerivationFramework::TrackParticleCaloCellDecorator::m_decCellRKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellRKey
Definition: TrackParticleCaloCellDecorator.h:40
CaloDetDescrElement::x
float x() const
cell x
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:363
CaloDetDescrElement::dphi
float dphi() const
cell dphi
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:358
DerivationFramework::TrackParticleCaloCellDecorator::m_decCellEKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellEKey
Definition: TrackParticleCaloCellDecorator.h:62
SG::WriteDecorHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
CaloDetDescrElement::dx
float dx() const
cell dx
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:375
CaloDetDescrElement::getSampling
CaloCell_ID::CaloSample getSampling() const
cell sampling
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:395
CaloDetDescrElement::z
float z() const
cell z
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:367
DerivationFramework::TrackParticleCaloCellDecorator::m_decCellQualityKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellQualityKey
Definition: TrackParticleCaloCellDecorator.h:68
CaloDetDescrElement::eta
float eta() const
cell eta
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:344
CaloDetDescrElement::phi
float phi() const
cell phi
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:346
xAOD::track
@ track
Definition: TrackingPrimitives.h:513
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:44
CaloDetDescrElement::r
float r() const
cell r
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:348
DerivationFramework::TrackParticleCaloCellDecorator::m_decCellProvenanceKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellProvenanceKey
Definition: TrackParticleCaloCellDecorator.h:70
CaloDetDescrElement::dy
float dy() const
cell dy
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:377
DerivationFramework::TrackParticleCaloCellDecorator::m_decCellEneDiffKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellEneDiffKey
Definition: TrackParticleCaloCellDecorator.h:74
DerivationFramework::TrackParticleCaloCellDecorator::addBranches
virtual StatusCode addBranches(const EventContext &ctx) const override final
Definition: TrackParticleCaloCellDecorator.cxx:46