ATLAS Offline Software
TrackParticleCaloCellDecorator.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 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  const std::string& n,
17  const IInterface* p) :
18  base_class(t, n, p){}
19 
21 
22  if ( m_sgName.empty() ) {
23  ATH_MSG_WARNING("No decoration prefix name provided for the output of TrackParticleCaloCellDecorator!");
24  return StatusCode::SUCCESS;
25  }
26  if ( m_trackContainerKey.empty() ) {
27  ATH_MSG_WARNING("No TrackParticle collection provided for TrackParticleCaloCellDecorator!");
28  return StatusCode::SUCCESS;
29  }
30 
52 
53  m_trackContainerKey = m_trackContainerKey.key() + "ClusterAssociations";
54  ATH_CHECK(m_trackContainerKey.initialize());
55 
77 
78  return StatusCode::SUCCESS;
79  }
80 
82 
83  const EventContext& ctx = Gaudi::Hive::currentContext();
85  ATH_CHECK( clusterAssociations.isValid() );
86 
108 
109  for(const auto clusterAssociation : *clusterAssociations) {
110  std::vector<float> trackCellEta(0, 0.);
111  std::vector<float> trackCellPhi(0, 0.);
112  std::vector<float> trackCellR(0, 0.);
113  std::vector<float> trackCelldEta(0, 0.);
114  std::vector<float> trackCelldPhi(0, 0.);
115  std::vector<float> trackCelldR(0, 0.);
116  std::vector<float> trackCellX(0, 0.);
117  std::vector<float> trackCellY(0, 0.);
118  std::vector<float> trackCellZ(0, 0.);
119  std::vector<float> trackCelldX(0, 0.);
120  std::vector<float> trackCelldY(0, 0.);
121  std::vector<float> trackCelldZ(0, 0.);
122  std::vector<float> trackCellT(0, 0.);
123  std::vector<float> trackCellE(0, 0.);
124  std::vector<unsigned int> trackCellID(0, 0);
125  std::vector<int> trackCellSampling(0, 0);
126  std::vector<int> trackCellQuality(0, 0);
127  std::vector<int> trackCellProvenance(0, 0);
128  std::vector<int> trackCellGain(0, 0);
129  std::vector<float> trackCellEneDiff(0, 0);
130  std::vector<float> trackCellTimeDiff(0, 0);
131 
132  const xAOD::TrackParticle* track = nullptr;
133  if (clusterAssociation->trackParticleLink().isValid()) {
134  track = *(clusterAssociation->trackParticleLink());
135  } else {
136  ATH_MSG_DEBUG ("trackParticleLink is not valid! " );
137  continue;
138  }
139 
140  for (const auto& cluster : clusterAssociation->caloClusterLinks()) {
141  const CaloClusterCellLink* cellLinks = (*cluster)->getCellLinks();
142 
143  trackCellEta.clear();
144  trackCellPhi.clear();
145  trackCellR.clear();
146  trackCelldEta.clear();
147  trackCelldPhi.clear();
148  trackCelldR.clear();
149  trackCellX.clear();
150  trackCellY.clear();
151  trackCellZ.clear();
152  trackCelldX.clear();
153  trackCelldY.clear();
154  trackCelldZ.clear();
155  trackCellT.clear();
156  trackCellE.clear();
157  trackCellID.clear();
158  trackCellSampling.clear();
159  trackCellQuality.clear();
160  trackCellProvenance.clear();
161  trackCellGain.clear();
162  trackCellEneDiff.clear();
163  trackCellTimeDiff.clear();
164 
165  if ( !cellLinks ) {
166  ATH_MSG_ERROR ("Unable to get cell links!");
167  continue;
168  }
169 
170  for(const auto cell : *cellLinks) {
171  const CaloDetDescrElement *caloDDE = cell->caloDDE();
172  int sampling = -1;
173  if ( caloDDE ) {
174  sampling = caloDDE->getSampling();
175  trackCellEta.emplace_back(caloDDE->eta());
176  trackCellPhi.emplace_back(caloDDE->phi());
177  trackCellR.emplace_back(caloDDE->r());
178  trackCelldEta.emplace_back(caloDDE->deta());
179  trackCelldPhi.emplace_back(caloDDE->dphi());
180  trackCelldR.emplace_back(caloDDE->dr());
181  trackCellX.emplace_back(caloDDE->x());
182  trackCellY.emplace_back(caloDDE->y());
183  trackCellZ.emplace_back(caloDDE->z());
184  trackCelldX.emplace_back(caloDDE->dx());
185  trackCelldY.emplace_back(caloDDE->dy());
186  trackCelldZ.emplace_back(caloDDE->dz());
187  trackCellT.emplace_back(cell->time());
188  trackCellE.emplace_back(cell->e());
189  Identifier32 IdOfCell = cell->ID().get_identifier32();
190  trackCellID.emplace_back(IdOfCell.get_compact());
191  trackCellSampling.emplace_back(sampling);
192  trackCellQuality.emplace_back(cell->quality());
193  trackCellProvenance.emplace_back(cell->provenance());
194  trackCellGain.emplace_back(cell->gain());
195  trackCellEneDiff.emplace_back(static_cast<const TileCell*>(cell)->eneDiff());
196  trackCellTimeDiff.emplace_back(static_cast<const TileCell*>(cell)->timeDiff());
197  } // if ( caloDDE )
198  } // for( cell )
199  } // for( cluster )
200 
201  decCellEta(*track) = trackCellEta;
202  decCellPhi(*track) = trackCellPhi;
203  decCellR(*track) = trackCellR;
204  decCelldEta(*track) = trackCelldEta;
205  decCelldPhi(*track) = trackCelldPhi;
206  decCelldR(*track) = trackCelldR;
207  decCellX(*track) = trackCellX;
208  decCellY(*track) = trackCellY;
209  decCellZ(*track) = trackCellZ;
210  decCelldX(*track) = trackCelldX;
211  decCelldY(*track) = trackCelldY;
212  decCelldZ(*track) = trackCelldZ;
213  decCellT(*track) = trackCellT;
214  decCellE(*track) = trackCellE;
215  decCellID(*track) = trackCellID;
216  decCellSampling(*track) = trackCellSampling;
217  decCellQuality(*track) = trackCellQuality;
218  decCellProvenance(*track) = trackCellProvenance;
219  decCellGain(*track) = trackCellGain;
220  decCellEneDiff(*track) = trackCellEneDiff;
221  decCellTimeDiff(*track) = trackCellTimeDiff;
222  }
223 
224 
225  return StatusCode::SUCCESS;
226  }
227 }
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:30
DerivationFramework::TrackParticleCaloCellDecorator::m_sgName
StringProperty m_sgName
Definition: TrackParticleCaloCellDecorator.h:28
Identifier32
Definition: Identifier32.h:25
DerivationFramework::TrackParticleCaloCellDecorator::m_decCellGainKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellGainKey
Definition: TrackParticleCaloCellDecorator.h:69
DerivationFramework::TrackParticleCaloCellDecorator::m_decCelldPhiKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCelldPhiKey
Definition: TrackParticleCaloCellDecorator.h:41
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
DerivationFramework::TrackParticleCaloCellDecorator::m_decCellTimeDiffKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellTimeDiffKey
Definition: TrackParticleCaloCellDecorator.h:73
CaloDetDescrElement::y
float y() const
cell y
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:365
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
DerivationFramework::TrackParticleCaloCellDecorator::m_decCelldEtaKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCelldEtaKey
Definition: TrackParticleCaloCellDecorator.h:39
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:49
DerivationFramework::TrackParticleCaloCellDecorator::m_decCellYKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellYKey
Definition: TrackParticleCaloCellDecorator.h:47
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:51
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
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:33
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:43
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
DerivationFramework::TrackParticleCaloCellDecorator::TrackParticleCaloCellDecorator
TrackParticleCaloCellDecorator(const std::string &t, const std::string &n, const IInterface *p)
Definition: TrackParticleCaloCellDecorator.cxx:15
beamspotman.n
n
Definition: beamspotman.py:731
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:55
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework::TrackParticleCaloCellDecorator::m_decCellXKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellXKey
Definition: TrackParticleCaloCellDecorator.h:45
DerivationFramework::TrackParticleCaloCellDecorator::m_decCellPhiKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellPhiKey
Definition: TrackParticleCaloCellDecorator.h:35
DerivationFramework::TrackParticleCaloCellDecorator::m_decCellIDKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellIDKey
Definition: TrackParticleCaloCellDecorator.h:61
DerivationFramework::TrackParticleCaloCellDecorator::initialize
virtual StatusCode initialize() override
Definition: TrackParticleCaloCellDecorator.cxx:20
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
DerivationFramework::TrackParticleCaloCellDecorator::m_decCelldYKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCelldYKey
Definition: TrackParticleCaloCellDecorator.h:53
DerivationFramework::TrackParticleCaloCellDecorator::m_decCellTKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellTKey
Definition: TrackParticleCaloCellDecorator.h:57
DerivationFramework::TrackParticleCaloCellDecorator::m_decCellSamplingKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellSamplingKey
Definition: TrackParticleCaloCellDecorator.h:63
DerivationFramework::TrackParticleCaloCellDecorator::m_decCellRKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_decCellRKey
Definition: TrackParticleCaloCellDecorator.h:37
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:59
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
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
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:65
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:512
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
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:67
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:71
DerivationFramework::TrackParticleCaloCellDecorator::addBranches
virtual StatusCode addBranches() const override
Definition: TrackParticleCaloCellDecorator.cxx:81