ATLAS Offline Software
InDetToXAODClusterConversion.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 #include "Identifier/Identifier.h"
10 #include "InDetIdentifier/SCT_ID.h"
14 
15 #include "StoreGate/WriteHandle.h"
16 #include "StoreGate/ReadHandle.h"
17 
20 
23 
25 #include <iterator>
26 
27 
28 
29 using namespace InDet;
30 
31 // Constructor with parameters:
32 InDetToXAODClusterConversion::InDetToXAODClusterConversion(const std::string &name, ISvcLocator *pSvcLocator) :
33 AthReentrantAlgorithm(name, pSvcLocator)
34 {}
35 
36 
37 //-----------------------------------------------------------------------------
38 // Initialize method:
40  ATH_MSG_INFO("Initializing " << name() << " ...");
41 
42  ATH_CHECK(detStore()->retrieve(m_pixelID,"PixelID"));
43  ATH_CHECK(detStore()->retrieve(m_stripID,"SCT_ID"));
44  ATH_CHECK(detStore()->retrieve(m_hgtdID,"HGTD_ID"));
45 
49 
54 
57 
58  ATH_MSG_DEBUG( "Initialize done !" );
59  return StatusCode::SUCCESS;
60 }
61 
62 //----------------------------------------------------------------------------
63 //
64 StatusCode InDetToXAODClusterConversion::execute(const EventContext& ctx) const {
65  ATH_MSG_DEBUG("Executing " << name() << " ...");
66 
67  if (m_processPixel.value()) {
68  ATH_MSG_DEBUG("Converting Pixel Clusters: InDet -> xAOD");
70  }
71 
72  if (m_processStrip.value()) {
73  ATH_MSG_DEBUG("Converting Strip Clusters: InDet -> xAOD");
75  }
76 
77  if (m_processHgtd.value()) {
78  ATH_MSG_DEBUG("Converting HGTD Clusters: InDet -> xAOD");
80  }
81 
82  return StatusCode::SUCCESS;
83 }
84 
87  const InDetDD::SiDetectorElementCollection* pixElements(*pixelDetEleHandle);
88  if (not pixelDetEleHandle.isValid() or pixElements==nullptr) {
89  ATH_MSG_FATAL(m_pixelDetEleCollKey.fullKey() << " is not available.");
90  return StatusCode::FAILURE;
91  }
92 
94  ATH_CHECK( outputPixelClusterContainer.record (std::make_unique<xAOD::PixelClusterContainer>(),
95  std::make_unique<xAOD::PixelClusterAuxContainer>()) );
96  ATH_MSG_DEBUG( "Recorded xAOD::PixelClusterContainer with key: " << m_outputPixelClusterContainerKey.key() );
97 
99 
100  static const SG::AuxElement::Accessor< ElementLink< InDet::PixelClusterCollection > > pixelLinkAcc("pixelClusterLink");
101  for (const auto *const clusterCollection : *inputPixelClusterContainer) {
102  if (!clusterCollection) continue;
103  for(const auto *const theCluster : *clusterCollection) {
104  Identifier clusterId = theCluster->identify();
105 
106  const InDetDD::SiDetectorElement *element=pixElements->getDetectorElement(m_pixelID->wafer_hash(m_pixelID->wafer_id(clusterId)));
107  if ( element==nullptr ) {
108  ATH_MSG_FATAL( "Invalid pixel detector element for cluster identifier " << clusterId );
109  return StatusCode::FAILURE;
110  }
111 
112  xAOD::PixelCluster * pixelCl = new xAOD::PixelCluster();
113  outputPixelClusterContainer->push_back(pixelCl);
114  ATH_CHECK( TrackingUtilities::convertInDetToXaodCluster(*theCluster, *element, *pixelCl) );
115 
116  // Create auxiliary branches accessors
117  ElementLink<InDet::PixelClusterCollection> pixelLink(theCluster, *clusterCollection);
118  pixelLinkAcc( *pixelCl ) = pixelLink;
119  }
120  }
121 
122  ATH_MSG_DEBUG("xAOD::PixelClusterContainer with size: " << outputPixelClusterContainer->size());
123  return StatusCode::SUCCESS;
124 }
125 
128  const InDetDD::SiDetectorElementCollection* stripElements(*stripDetEleHandle);
129  if (not stripDetEleHandle.isValid() or stripElements==nullptr) {
130  ATH_MSG_FATAL(m_stripDetEleCollKey.fullKey() << " is not available.");
131  return StatusCode::FAILURE;
132  }
133 
135  ATH_CHECK( outputStripClusterContainer.record (std::make_unique<xAOD::StripClusterContainer>(),
136  std::make_unique<xAOD::StripClusterAuxContainer>()) );
137  ATH_MSG_DEBUG( "Recorded xAOD::StripClusterContainer with key: " << m_outputStripClusterContainerKey.key() );
138 
140 
141  static const SG::AuxElement::Accessor< ElementLink< InDet::SCT_ClusterCollection > > stripLinkAcc("sctClusterLink");
142  for (const auto *const clusterCollection : *inputStripClusterContainer) {
143  if (!clusterCollection) continue;
144  for(const auto *const theCluster : *clusterCollection) {
145  Identifier clusterId = theCluster->identify();
146 
147  const InDetDD::SiDetectorElement *element=stripElements->getDetectorElement(m_stripID->wafer_hash(m_stripID->wafer_id(clusterId)));
148  if ( element==nullptr ) {
149  ATH_MSG_FATAL( "Invalid strip detector element for cluster with identifier " << clusterId );
150  return StatusCode::FAILURE;
151  }
152 
153 
154  xAOD::StripCluster * stripCl = new xAOD::StripCluster();
155  outputStripClusterContainer->push_back(stripCl);
156  ATH_CHECK( TrackingUtilities::convertInDetToXaodCluster(*theCluster, *element, *stripCl) );
157 
158  // Create auxiliary branches accessors
159  ElementLink<InDet::SCT_ClusterCollection> stripLink(theCluster, *clusterCollection);
160  stripLinkAcc( *stripCl ) = stripLink;
161  }
162  }
163 
164  ATH_MSG_DEBUG("xAOD::StripClusterContainer with size: " << outputStripClusterContainer->size());
165 
166  return StatusCode::SUCCESS;
167 }
168 
171  const InDetDD::HGTD_DetectorElementCollection* hgtdElements(*hgtdDetEleHandle);
172  if (not hgtdDetEleHandle.isValid() or hgtdElements==nullptr) {
173  ATH_MSG_FATAL(m_HGTDDetEleCollKey.fullKey() << " is not available.");
174  return StatusCode::FAILURE;
175  }
176 
178  ATH_CHECK( outputHgtdClusterContainer.record (std::make_unique<xAOD::HGTDClusterContainer>(),
179  std::make_unique<xAOD::HGTDClusterAuxContainer>()) );
180  ATH_MSG_DEBUG( "Recorded xAOD::HGTDClusterContainer with key: " << m_outputHgtdClusterContainerKey.key() );
181 
183  ATH_CHECK(inputHgtdClusterContainer.isValid());
184 
185  static const SG::AuxElement::Accessor< ElementLink< ::HGTD_ClusterCollection > > hgtdLinkAcc("hgtdClusterLink");
186  for (const auto *const clusterCollection : *inputHgtdClusterContainer) {
187  if (!clusterCollection) continue;
188  for(const auto *const theCluster : *clusterCollection) {
189  Identifier clusterId = theCluster->identify();
190 
191  const auto *element=hgtdElements->getDetectorElement(m_hgtdID->wafer_hash(m_hgtdID->wafer_id(clusterId)));
192  if ( element==nullptr ) {
193  ATH_MSG_FATAL( "Invalid strip detector element for cluster with identifier " << clusterId );
194  return StatusCode::FAILURE;
195  }
196 
197  xAOD::HGTDCluster * hgtdCl = new xAOD::HGTDCluster();
198  outputHgtdClusterContainer->push_back(hgtdCl);
199  ATH_CHECK( TrackingUtilities::convertInDetToXaodCluster(*theCluster, *element, *hgtdCl) );
200 
201  // Create auxiliary branches accessors
202  ElementLink<::HGTD_ClusterCollection> hgtdLink(theCluster, *clusterCollection);
203  hgtdLinkAcc( *hgtdCl ) = hgtdLink;
204  }
205  }
206 
207  ATH_MSG_DEBUG("xAOD::HGTDClusterContainer with size: " << outputHgtdClusterContainer->size());
208  return StatusCode::SUCCESS;
209 }
210 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
TrackingUtilities::convertInDetToXaodCluster
StatusCode convertInDetToXaodCluster(const InDet::PixelCluster &indetCluster, const InDetDD::SiDetectorElement &element, xAOD::PixelCluster &xaodCluster)
Definition: ClusterConversionUtilities.cxx:52
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
InDet::InDetToXAODClusterConversion::m_hgtdID
const HGTD_ID * m_hgtdID
Definition: InDetToXAODClusterConversion.h:70
InDet::InDetToXAODClusterConversion::m_inputPixelClusterContainerKey
SG::ReadHandleKey< InDet::PixelClusterContainer > m_inputPixelClusterContainerKey
Definition: InDetToXAODClusterConversion.h:76
InDetDD::SiDetectorElementCollection
Definition: SiDetectorElementCollection.h:30
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
HGTD_ID::wafer_hash
IdentifierHash wafer_hash(Identifier wafer_id) const
wafer hash from id
Definition: HGTD_ID.h:404
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:66
InDet::InDetToXAODClusterConversion::convertHgtdClusters
StatusCode convertHgtdClusters(const EventContext &ctx) const
Definition: InDetToXAODClusterConversion.cxx:169
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
InDet
DUMMY Primary Vertex Finder.
Definition: VP1ErrorUtils.h:36
xAOD::HGTDCluster
HGTDCluster_v1 HGTDCluster
Define the version of the pixel cluster class.
Definition: HGTDCluster.h:13
InDet::InDetToXAODClusterConversion::m_outputHgtdClusterContainerKey
SG::WriteHandleKey< xAOD::HGTDClusterContainer > m_outputHgtdClusterContainerKey
Definition: InDetToXAODClusterConversion.h:83
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:205
xAOD::HGTDCluster_v1
Definition: HGTDCluster_v1.h:23
InDet::InDetToXAODClusterConversion::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: InDetToXAODClusterConversion.cxx:64
InDet::InDetToXAODClusterConversion::m_outputPixelClusterContainerKey
SG::WriteHandleKey< xAOD::PixelClusterContainer > m_outputPixelClusterContainerKey
Definition: InDetToXAODClusterConversion.h:79
InDet::InDetToXAODClusterConversion::convertStripClusters
StatusCode convertStripClusters(const EventContext &ctx) const
Definition: InDetToXAODClusterConversion.cxx:126
InDet::InDetToXAODClusterConversion::convertPixelClusters
StatusCode convertPixelClusters(const EventContext &ctx) const
Definition: InDetToXAODClusterConversion.cxx:85
PixelID::wafer_id
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
Definition: PixelID.h:364
HGTD_ID::wafer_id
Identifier wafer_id(int endcap, int layer, int phi_module, int eta_module) const
For a single crystal.
Definition: HGTD_ID.h:287
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
InDet::InDetToXAODClusterConversion::m_pixelDetEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_pixelDetEleCollKey
Definition: InDetToXAODClusterConversion.h:72
WriteHandle.h
Handle class for recording to StoreGate.
xAOD::StripCluster
StripCluster_v1 StripCluster
Define the version of the strip cluster class.
Definition: StripCluster.h:13
SCT_ClusterCollection.h
PixelID::wafer_hash
IdentifierHash wafer_hash(Identifier wafer_id) const
wafer hash from id
Definition: PixelID.h:387
InDet::InDetToXAODClusterConversion::m_processStrip
Gaudi::Property< bool > m_processStrip
Definition: InDetToXAODClusterConversion.h:86
PixelClusterAuxContainer.h
xAOD::PixelCluster
PixelCluster_v1 PixelCluster
Define the version of the pixel cluster class.
Definition: Event/xAOD/xAODInDetMeasurement/xAODInDetMeasurement/PixelCluster.h:13
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
InDet::InDetToXAODClusterConversion::InDetToXAODClusterConversion
InDetToXAODClusterConversion()=delete
xAOD::StripCluster_v1
Definition: StripCluster_v1.h:17
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SCT_ID::wafer_hash
IdentifierHash wafer_hash(const Identifier &wafer_id) const
wafer hash from id - optimized
Definition: SCT_ID.h:492
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
InDet::InDetToXAODClusterConversion::m_stripID
const SCT_ID * m_stripID
Definition: InDetToXAODClusterConversion.h:69
PixelClusterCollection.h
ClusterConversionUtilities.h
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
InDet::InDetToXAODClusterConversion::m_inputHgtdClusterContainerKey
SG::ReadHandleKey<::HGTD_ClusterContainer > m_inputHgtdClusterContainerKey
Definition: InDetToXAODClusterConversion.h:82
HGTD_ID.h
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
InDet::InDetToXAODClusterConversion::m_pixelID
const PixelID * m_pixelID
Definition: InDetToXAODClusterConversion.h:68
SiDetectorElement.h
InDet::InDetToXAODClusterConversion::m_stripDetEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_stripDetEleCollKey
Definition: InDetToXAODClusterConversion.h:73
StripClusterAuxContainer.h
StripStereoAnnulusDesign.h
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
DataVector.h
An STL vector of pointers that by default owns its pointed-to elements.
xAOD::PixelCluster_v1
Definition: PixelCluster_v1.h:17
InDet::InDetToXAODClusterConversion::m_HGTDDetEleCollKey
SG::ReadCondHandleKey< InDetDD::HGTD_DetectorElementCollection > m_HGTDDetEleCollKey
Definition: InDetToXAODClusterConversion.h:74
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
InDet::InDetToXAODClusterConversion::m_processHgtd
Gaudi::Property< bool > m_processHgtd
Definition: InDetToXAODClusterConversion.h:87
InDet::InDetToXAODClusterConversion::m_inputStripClusterContainerKey
SG::ReadHandleKey< InDet::SCT_ClusterContainer > m_inputStripClusterContainerKey
Definition: InDetToXAODClusterConversion.h:77
InDetToXAODClusterConversion.h
ReadHandle.h
Handle class for reading from StoreGate.
SCT_ID::wafer_id
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module, int side) const
For a single side of module.
Definition: SCT_ID.h:464
InDet::InDetToXAODClusterConversion::initialize
virtual StatusCode initialize() override
Definition: InDetToXAODClusterConversion.cxx:39
InDetDD::HGTD_DetectorElementCollection
Definition: HGTD_DetectorElementCollection.h:29
InDetDD::HGTD_DetectorElementCollection::getDetectorElement
const HGTD_DetectorElement * getDetectorElement(const IdentifierHash &hash) const
Definition: HGTD_DetectorElementCollection.cxx:11
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
InDetDD::SiDetectorElementCollection::getDetectorElement
const SiDetectorElement * getDetectorElement(const IdentifierHash &hash) const
Definition: SiDetectorElementCollection.cxx:15
InDet::InDetToXAODClusterConversion::m_outputStripClusterContainerKey
SG::WriteHandleKey< xAOD::StripClusterContainer > m_outputStripClusterContainerKey
Definition: InDetToXAODClusterConversion.h:80
InDet::InDetToXAODClusterConversion::m_processPixel
Gaudi::Property< bool > m_processPixel
Definition: InDetToXAODClusterConversion.h:85