Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
StripClusterTruthDecoratorAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 namespace ActsTrk {
9 
11  ISvcLocator *pSvcLocator) :
12  AthReentrantAlgorithm(name, pSvcLocator)
13  {}
14 
15 
17  ATH_MSG_DEBUG("Initialize " << name() << " ...");
18 
19  // Read keys
23 
24  // Write keys
25  ATH_CHECK(m_write_xaod_key.initialize());
26 
27  // Decorator
30 
46 
49 
51  ATH_CHECK(m_measurement_waferID.initialize());
52  ATH_CHECK(m_measurement_bec.initialize());
53  ATH_CHECK(m_measurement_layer.initialize());
54  ATH_CHECK(m_measurement_sizePhi.initialize());
55  ATH_CHECK(m_measurement_sizeZ.initialize());
56  ATH_CHECK(m_measurement_SiWidth.initialize());
57  ATH_CHECK(m_measurement_eta_module.initialize());
58  ATH_CHECK(m_measurement_phi_module.initialize());
59  ATH_CHECK(m_measurement_omegax.initialize());
60  ATH_CHECK(m_measurement_omegay.initialize());
64  ATH_CHECK(m_measurement_side.initialize());
65 
67 
68  return StatusCode::SUCCESS;
69  }
70 
71  StatusCode StripClusterTruthDecoratorAlg::execute(const EventContext& ctx) const {
72 
75  const xAOD::StripClusterContainer *stripClusters = StripClusterContainer.cptr();
76 
78  ATH_CHECK(stripDetEleHandle.isValid());
79  const InDetDD::SiDetectorElementCollection* stripElements = stripDetEleHandle.cptr();
80 
81  const ActsTrk::MeasurementToTruthParticleAssociation* measToTruth(nullptr);
82  if (m_useTruthInfo) {
84  ATH_CHECK( measToTruthHandle.isValid());
85  measToTruth = measToTruthHandle.ptr();
86  }
87 
88  // Setup outputs
89  // Create the xAOD container and its auxiliary store:
91  ATH_CHECK(xaod.record(std::make_unique<xAOD::TrackMeasurementValidationContainer>(),
92  std::make_unique<xAOD::TrackMeasurementValidationAuxContainer>()));
93  xAOD::TrackMeasurementValidationContainer* measurements = xaod.ptr();
94 
95 
111 
112  std::vector<xAOD::TrackMeasurementValidation*> toAdd(stripClusters->size(), nullptr);
113  for (std::size_t i(0); i<toAdd.size(); ++i) {
115  }
116  measurements->insert(measurements->end(), toAdd.begin(), toAdd.end());
117 
118  // loop over collection and convert to xAOD::TrackMeasurementValidation
119  for (std::size_t i(0); i<stripClusters->size(); ++i) {
120  const xAOD::StripCluster* cluster = stripClusters->at(i);
121  xAOD::TrackMeasurementValidation *measurement = measurements->at(i);
122 
123  xAOD::DetectorIdentType clusterId = cluster->identifier();
124  xAOD::DetectorIDHashType hashId = cluster->identifierHash();
125 
126  const InDetDD::SiDetectorElement *element = stripElements->getDetectorElement(hashId);
127  if ( not element ) {
128  ATH_MSG_FATAL( "Invalid strip detector element for hash " << hashId );
129  return StatusCode::FAILURE;
130  }
131 
132  const std::vector<Identifier> rdoList = cluster->rdoList();
133  std::vector< std::uint64_t > rdoIdentifierList;
134  rdoIdentifierList.reserve(rdoList.size());
135  for( const Identifier& hitIdentifier : rdoList ){
136  rdoIdentifierList.push_back( hitIdentifier.get_compact() );
137  }
138 
139  //Set Identifier
140  measurement->setIdentifier( clusterId );
141  measurement->setRdoIdentifierList(std::move(rdoIdentifierList));
142 
143  //Set Global Position
144  auto gpos = cluster->globalPosition();
145  measurement->setGlobalPosition(gpos.x(), gpos.y(), gpos.z());
146 
147  // Set local position and error matrix
148  auto locpos = cluster->localPosition<1>();
149  measurement->setLocalPosition(locpos[0], locpos[1]);
150 
151  auto localCov = cluster->localCovariance<1>();
152  measurement->setLocalPositionError( localCov(0,0), 0., 0. );
153 
154  const Identifier waferId = m_stripHelper->wafer_id(hashId);
155  decor_detectorElementID(*measurement) = hashId;
156  decor_waferID(*measurement) = waferId.get_compact();
157  decor_bec(*measurement) = m_stripHelper->barrel_ec(waferId);
158  decor_layer(*measurement) = m_stripHelper->layer_disk(waferId);
159  decor_sizePhi(*measurement) = cluster->channelsInPhi();
160  decor_sizeZ(*measurement) = 0;
161  decor_SiWidth(*measurement) = cluster->channelsInPhi();
162  decor_eta_module(*measurement) = m_stripHelper->eta_module(waferId);
163  decor_phi_module(*measurement) = m_stripHelper->phi_module(waferId);
164  decor_omegax(*measurement) = 0;
165  decor_omegay(*measurement) = 0;
166  decor_LorentzShift(*measurement) = 0;
167  decor_centroid_xphi(*measurement) = 0;
168  decor_centroid_xeta(*measurement) = 0;
169  decor_side(*measurement) = m_stripHelper->side(waferId);
170  }
171 
172 
173  // Get a list of all true particle contributing to the cluster
174  if (m_useTruthInfo) {
177 
178  for (std::size_t i(0); i<stripClusters->size(); ++i) {
179  const xAOD::StripCluster* cluster = stripClusters->at(i);
180  xAOD::TrackMeasurementValidation *measurement = measurements->at(i);
181 
182  if (cluster->index() >= measToTruth->size()) {
183  ATH_MSG_ERROR("PRD index "<< cluster->index() << " not present in the measurement to truth vector with size " << measToTruth->size());
184  return StatusCode::FAILURE;
185  }
186 
187  auto tps = measToTruth->at(cluster->index());
188 
189  std::vector<unsigned int> tp_indices;
190  std::vector<unsigned int> tp_barcodes;
191  for (auto tp : tps) {
192  tp_indices.push_back(tp->index());
193  tp_barcodes.push_back(HepMC::barcode(tp));
194  }
195 
196  decor_truth_indices(*measurement) = std::move(tp_indices);
197  decor_truth_barcode(*measurement) = std::move(tp_barcodes);
198  } // loop on clusters
199  }
200 
201  ATH_MSG_DEBUG( " recorded StripPrepData objects: size " << measurements->size() );
202  return StatusCode::SUCCESS;
203  }
204 
205 } // ActsTrk
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ActsTrk::StripClusterTruthDecoratorAlg::m_measurement_centroid_xeta
SG::WriteDecorHandleKey< xAOD::TrackMeasurementValidationContainer > m_measurement_centroid_xeta
Definition: StripClusterTruthDecoratorAlg.h:66
xAOD::DetectorIdentType
long unsigned int DetectorIdentType
Definition: MeasurementDefs.h:44
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ActsTrk::StripClusterTruthDecoratorAlg::m_stripHelper
const SCT_ID * m_stripHelper
Definition: StripClusterTruthDecoratorAlg.h:70
InDetDD::SiDetectorElementCollection
Definition: SiDetectorElementCollection.h:30
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ActsTrk::StripClusterTruthDecoratorAlg::m_measurement_layer
SG::WriteDecorHandleKey< xAOD::TrackMeasurementValidationContainer > m_measurement_layer
Definition: StripClusterTruthDecoratorAlg.h:56
ActsTrk::StripClusterTruthDecoratorAlg::m_measurement_SiWidth
SG::WriteDecorHandleKey< xAOD::TrackMeasurementValidationContainer > m_measurement_SiWidth
Definition: StripClusterTruthDecoratorAlg.h:59
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
ActsTrk::StripClusterTruthDecoratorAlg::m_measurement_sizeZ
SG::WriteDecorHandleKey< xAOD::TrackMeasurementValidationContainer > m_measurement_sizeZ
Definition: StripClusterTruthDecoratorAlg.h:58
xAOD::TrackMeasurementValidation
TrackMeasurementValidation_v1 TrackMeasurementValidation
Reference the current persistent version:
Definition: TrackMeasurementValidation.h:13
ActsTrk::StripClusterTruthDecoratorAlg::m_measurement_centroid_xphi
SG::WriteDecorHandleKey< xAOD::TrackMeasurementValidationContainer > m_measurement_centroid_xphi
Definition: StripClusterTruthDecoratorAlg.h:65
ActsTrk::StripClusterTruthDecoratorAlg::initialize
virtual StatusCode initialize() override
Definition: StripClusterTruthDecoratorAlg.cxx:16
ActsTrk::StripClusterTruthDecoratorAlg::m_write_xaod_key
SG::WriteHandleKey< xAOD::TrackMeasurementValidationContainer > m_write_xaod_key
Definition: StripClusterTruthDecoratorAlg.h:49
ActsTrk::StripClusterTruthDecoratorAlg::m_measurement_truth_barcodes
SG::WriteDecorHandleKey< xAOD::TrackMeasurementValidationContainer > m_measurement_truth_barcodes
Definition: StripClusterTruthDecoratorAlg.h:51
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:210
ParticleTest.tp
tp
Definition: ParticleTest.py:25
Identifier::get_compact
value_type get_compact() const
Get the compact id.
ActsTrk::StripClusterTruthDecoratorAlg::m_measurement_LorentzShift
SG::WriteDecorHandleKey< xAOD::TrackMeasurementValidationContainer > m_measurement_LorentzShift
Definition: StripClusterTruthDecoratorAlg.h:64
ActsTrk::StripClusterTruthDecoratorAlg::m_measurement_truth_indices
SG::WriteDecorHandleKey< xAOD::TrackMeasurementValidationContainer > m_measurement_truth_indices
Definition: StripClusterTruthDecoratorAlg.h:50
SCT_ID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: SCT_ID.h:728
xAOD::TrackMeasurementValidation_v1::setRdoIdentifierList
void setRdoIdentifierList(const std::vector< uint64_t > &rdoIdentifierList)
Sets the list of RDO identifiers.
SCT_ID::phi_module
int phi_module(const Identifier &id) const
Definition: SCT_ID.h:740
ActsTrk::StripClusterTruthDecoratorAlg::m_stripDetEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_stripDetEleCollKey
Definition: StripClusterTruthDecoratorAlg.h:47
ActsTrk::StripClusterTruthDecoratorAlg::m_measurement_omegax
SG::WriteDecorHandleKey< xAOD::TrackMeasurementValidationContainer > m_measurement_omegax
Definition: StripClusterTruthDecoratorAlg.h:62
ActsTrk::MeasurementToTruthParticleAssociation
Definition: MeasurementToTruthParticleAssociation.h:18
StripClusterTruthDecoratorAlg.h
ActsTrk::StripClusterTruthDecoratorAlg::m_measurement_side
SG::WriteDecorHandleKey< xAOD::TrackMeasurementValidationContainer > m_measurement_side
Definition: StripClusterTruthDecoratorAlg.h:67
ActsTrk::StripClusterTruthDecoratorAlg::m_associationMap_key
SG::ReadHandleKey< MeasurementToTruthParticleAssociation > m_associationMap_key
Definition: StripClusterTruthDecoratorAlg.h:46
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:74
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:274
ActsTrk::StripClusterTruthDecoratorAlg::StripClusterTruthDecoratorAlg
StripClusterTruthDecoratorAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: StripClusterTruthDecoratorAlg.cxx:10
xAOD::TrackMeasurementValidation_v1
Class describing a TrackMeasurementValidation.
Definition: TrackMeasurementValidation_v1.h:27
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ActsTrk::StripClusterTruthDecoratorAlg::m_measurement_bec
SG::WriteDecorHandleKey< xAOD::TrackMeasurementValidationContainer > m_measurement_bec
Definition: StripClusterTruthDecoratorAlg.h:55
xAOD::TrackMeasurementValidation_v1::setLocalPosition
void setLocalPosition(float localX, float localY)
Sets the local position.
lumiFormat.i
int i
Definition: lumiFormat.py:85
ActsTrk::StripClusterTruthDecoratorAlg::m_measurement_sizePhi
SG::WriteDecorHandleKey< xAOD::TrackMeasurementValidationContainer > m_measurement_sizePhi
Definition: StripClusterTruthDecoratorAlg.h:57
ActsTrk::StripClusterTruthDecoratorAlg::m_measurement_waferID
SG::WriteDecorHandleKey< xAOD::TrackMeasurementValidationContainer > m_measurement_waferID
Definition: StripClusterTruthDecoratorAlg.h:54
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
ActsTrk::StripClusterTruthDecoratorAlg::m_measurement_omegay
SG::WriteDecorHandleKey< xAOD::TrackMeasurementValidationContainer > m_measurement_omegay
Definition: StripClusterTruthDecoratorAlg.h:63
ActsTrk::StripClusterTruthDecoratorAlg::m_measurement_detectorElementID
SG::WriteDecorHandleKey< xAOD::TrackMeasurementValidationContainer > m_measurement_detectorElementID
Definition: StripClusterTruthDecoratorAlg.h:53
xAOD::StripCluster_v1
Definition: StripCluster_v1.h:17
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector::insert
iterator insert(iterator position, value_type pElem)
Add a new element to the collection.
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
xAOD::TrackMeasurementValidation_v1::setIdentifier
void setIdentifier(uint64_t identifier)
Sets the identifier.
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
DeMoUpdate.toAdd
bool toAdd
Definition: DeMoUpdate.py:1304
ActsTrk::StripClusterTruthDecoratorAlg::m_measurement_phi_module
SG::WriteDecorHandleKey< xAOD::TrackMeasurementValidationContainer > m_measurement_phi_module
Definition: StripClusterTruthDecoratorAlg.h:61
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
xAOD::TrackMeasurementValidation_v1::setGlobalPosition
void setGlobalPosition(float globalX, float globalY, float globalZ)
Sets the global position.
Definition: TrackMeasurementValidation_v1.cxx:50
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
xAOD::DetectorIDHashType
unsigned int DetectorIDHashType
@ detector ID element hash
Definition: MeasurementDefs.h:43
xAOD::TrackMeasurementValidation_v1::setLocalPositionError
void setLocalPositionError(float localXError, float localYError, float localXYCorrelation)
Sets the local position error.
Definition: TrackMeasurementValidation_v1.cxx:37
SCT_ID::layer_disk
int layer_disk(const Identifier &id) const
Definition: SCT_ID.h:734
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
ActsTrk::StripClusterTruthDecoratorAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: StripClusterTruthDecoratorAlg.cxx:71
SG::ReadHandle::ptr
const_pointer_type ptr()
Dereference the pointer.
xAOD::StripClusterContainer
StripClusterContainer_v1 StripClusterContainer
Define the version of the strip cluster container.
Definition: StripClusterContainer.h:14
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
SCT_ID::eta_module
int eta_module(const Identifier &id) const
Definition: SCT_ID.h:746
SCT_ID::side
int side(const Identifier &id) const
Definition: SCT_ID.h:752
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MuonDetectorBuilderTool.cxx:55
ActsTrk::StripClusterTruthDecoratorAlg::m_clustercontainer_key
SG::ReadHandleKey< xAOD::StripClusterContainer > m_clustercontainer_key
Definition: StripClusterTruthDecoratorAlg.h:45
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
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
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
HepMCHelpers.h
ActsTrk::StripClusterTruthDecoratorAlg::m_measurement_eta_module
SG::WriteDecorHandleKey< xAOD::TrackMeasurementValidationContainer > m_measurement_eta_module
Definition: StripClusterTruthDecoratorAlg.h:60
SG::ReadCondHandle::cptr
const_pointer_type cptr()
Definition: ReadCondHandle.h:71
ActsTrk::StripClusterTruthDecoratorAlg::m_useTruthInfo
Gaudi::Property< bool > m_useTruthInfo
Definition: StripClusterTruthDecoratorAlg.h:69
Identifier
Definition: IdentifierFieldParser.cxx:14