ATLAS Offline Software
SpacePointAnalysisAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
13 
14 namespace ActsTrk {
15  SpacePointAnalysisAlg::SpacePointAnalysisAlg(const std::string& name, ISvcLocator *pSvcLocator)
16  : AthMonitorAlgorithm(name, pSvcLocator)
17  {}
18 
20  ATH_MSG_DEBUG( "Initializing " << name() << " ... " );
21 
23 
24  ATH_MSG_DEBUG("Properties:");
27 
28  ATH_CHECK( m_spacePointContainerKey.initialize() );
29  ATH_CHECK( m_clusterDecoration.initialize() );
30 
31  if (m_usePixel and m_useOverlap)
32  ATH_MSG_INFO("No overlap collection when enabled for pixel space points! Check your configuration if needed.");
33 
34  ATH_MSG_DEBUG("Monitoring settings ...");
36 
38  }
39 
40  StatusCode SpacePointAnalysisAlg::fillHistograms(const EventContext& ctx) const {
41  ATH_MSG_DEBUG(" In " << name() << "::fillHistograms()" );
42 
43  const PixelID *pixelID = nullptr;
44  const SCT_ID *stripID = nullptr;
45 
46  if (m_usePixel)
47  ATH_CHECK(detStore()->retrieve(pixelID, "PixelID"));
48  else
49  ATH_CHECK(detStore()->retrieve(stripID, "SCT_ID"));
50 
52  if (!inputSpacePointContainer.isValid()){
53  ATH_MSG_FATAL("xAOD::SpacePointContainer with key " << m_spacePointContainerKey.key() << " is not available...");
54  return StatusCode::FAILURE;
55  }
56  const xAOD::SpacePointContainer* inputSpacePointCollection = inputSpacePointContainer.cptr();
57  // Early exit if no input collection
58  if (inputSpacePointCollection->size() == 0) {
59  return StatusCode::SUCCESS;
60  }
61 
62  ATH_MSG_DEBUG("Reading decoration to space point collection: bare pointers to clusters");
63  ATH_MSG_DEBUG("Decoration name: " << m_clusterDecoration.key());
64  using decoration_type = std::vector<const xAOD::UncalibratedMeasurement*>;
66  decoration_type > barePointersToClusters( m_clusterDecoration, ctx );
67  static const SG::ConstAccessor<decoration_type> measurementsAcc ("measurements");
68  if ( not barePointersToClusters.isAvailable() and
69  not measurementsAcc.isAvailable (*inputSpacePointCollection->front()) ) {
70  ATH_MSG_ERROR("Space Point Collection does not have decoration 'measurements', which should contain a vector of bare pointes to clusters");
71  return StatusCode::FAILURE;
72  }
73 
74  auto monitor_nsp = Monitored::Scalar<int>("Nsp", inputSpacePointContainer->size());
75  fill(m_monGroupName.value(), monitor_nsp);
76 
77  // Check we can have access to clusters
78  for (const xAOD::SpacePoint* sp : *inputSpacePointCollection) {
79  const auto& els = sp->measurements();
80  for (const auto* el : els) {
81  [[maybe_unused]] const auto idHash = el->identifierHash();
82  }
83  }
84 
85  auto monitor_barrelEndcap = Monitored::Collection("barrelEndcap", *inputSpacePointCollection,
86  [this, &pixelID, &stripID] (const auto* spacePoint) -> int
87  {
88  const auto idHash = spacePoint->elementIdList()[0];
89  const Identifier id = this->m_usePixel ?
90  pixelID->wafer_id(idHash) : stripID->wafer_id(idHash);
91  return this->m_usePixel ? pixelID->barrel_ec(id) : stripID->barrel_ec(id);
92  });
93  auto monitor_layerDisk = Monitored::Collection("layerDisk", *inputSpacePointCollection,
94  [this, &pixelID, &stripID] (const auto* spacePoint) -> int
95  {
96  const auto idHash = spacePoint->elementIdList()[0];
97  const Identifier id = this->m_usePixel ?
98  pixelID->wafer_id(idHash) : stripID->wafer_id(idHash);
99  return this->m_usePixel ? pixelID->layer_disk(id) : stripID->layer_disk(id);
100  });
101 
102  auto monitor_phiModule = Monitored::Collection("phiModule", *inputSpacePointCollection,
103  [this, &pixelID, &stripID] (const auto* spacePoint) -> int
104  {
105  const auto idHash = spacePoint->elementIdList()[0];
106  const Identifier id = this->m_usePixel ?
107  pixelID->wafer_id(idHash) : stripID->wafer_id(idHash);
108  return this->m_usePixel ? pixelID->phi_module(id) : stripID->phi_module(id);
109  });
110  auto monitor_etaModule = Monitored::Collection("etaModule", *inputSpacePointCollection,
111  [this, &pixelID, &stripID] (const auto* spacePoint) -> int
112  {
113  const auto idHash = spacePoint->elementIdList()[0];
114  const Identifier id = this->m_usePixel ?
115  pixelID->wafer_id(idHash) : stripID->wafer_id(idHash);
116  return this->m_usePixel ? pixelID->eta_module(id) : stripID->eta_module(id);
117  });
118  auto monitor_sideModule = Monitored::Collection("sideModule", *inputSpacePointCollection,
119  [this, &stripID] (const auto* spacePoint) -> int
120  {
121  if (this->m_usePixel) return 0;
122 
123  const auto idHash = spacePoint->elementIdList()[0];
124  const Identifier id = stripID->wafer_id(idHash);
125  return stripID->side(id);
126  });
127 
128  auto monitor_isInnermost = Monitored::Collection("isInnermost", *inputSpacePointCollection,
129  [this, &pixelID] (const auto* spacePoint) -> int
130  {
131  if (not this->m_usePixel) return 0;
132 
133  const auto idHash = spacePoint->elementIdList()[0];
134  const Identifier id = pixelID->wafer_id(idHash);
135  const int layerDisk = pixelID->layer_disk(id);
136  return int(layerDisk==0);
137  });
138  auto monitor_isNextToInnermost = Monitored::Collection("isNextToInnermost", *inputSpacePointCollection,
139  [this, &pixelID] (const auto* spacePoint) -> int
140  {
141  if (not this->m_usePixel) return 0;
142 
143  const auto idHash = spacePoint->elementIdList()[0];
144  const Identifier id = pixelID->wafer_id(idHash);
145 
146  const int brlEc = pixelID->layer_disk(id);
147  const int layerDisk = pixelID->layer_disk(id);
148  return int((layerDisk==1) or (brlEc!=0 and layerDisk==2));
149  });
150  auto monitor_isOverlap = Monitored::Collection("isOverlap", *inputSpacePointCollection,
151  [this] (const auto*) -> int
152  {
153  return this->m_usePixel ? 0 : int(this->m_useOverlap);
154  });
155 
156  auto monitor_eta = Monitored::Collection("eta", *inputSpacePointCollection,
157  [] (const auto* spacePoint) -> double
158  {
159  Amg::Vector3D globalPosition(spacePoint->x(), spacePoint->y(), spacePoint->z());
160  return globalPosition.eta();
161  });
162  auto monitor_perp = Monitored::Collection("perp", *inputSpacePointCollection,
163  [] (const auto* spacePoint) -> double
164  {
165  Amg::Vector3D globalPosition(spacePoint->x(), spacePoint->y(), spacePoint->z());
166  return globalPosition.perp();
167  });
168 
169  auto monitor_globalX = Monitored::Collection("globalX", *inputSpacePointCollection,
170  [] (const auto* spacePoint) -> double
171  { return spacePoint->x(); });
172  auto monitor_globalY = Monitored::Collection("globalY", *inputSpacePointCollection,
173  [] (const auto* spacePoint) -> double
174  { return spacePoint->y(); });
175  auto monitor_globalZ = Monitored::Collection("globalZ", *inputSpacePointCollection,
176  [] (const auto* spacePoint) -> double
177  { return spacePoint->z(); });
178 
179  auto monitor_cov_r = Monitored::Collection("globalCovR", *inputSpacePointCollection,
180  [] (const auto* spacePoint) -> double
181  { return spacePoint->varianceR(); });
182  auto monitor_cov_z = Monitored::Collection("globalCovZ", *inputSpacePointCollection,
183  [] (const auto* spacePoint) -> double
184  { return spacePoint->varianceZ(); });
185 
186  fill(m_monGroupName.value(),
187  monitor_barrelEndcap, monitor_layerDisk,
188  monitor_phiModule, monitor_etaModule, monitor_sideModule,
189  monitor_isInnermost, monitor_isNextToInnermost,
190  monitor_isOverlap,
191  monitor_eta, monitor_perp,
192  monitor_globalX, monitor_globalY, monitor_globalZ,
193  monitor_cov_r, monitor_cov_z);
194 
195  return StatusCode::SUCCESS;
196  }
197 
198 }
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...
ActsTrk::SpacePointAnalysisAlg::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: SpacePointAnalysisAlg.cxx:40
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...
ActsTrk::SpacePointAnalysisAlg::initialize
virtual StatusCode initialize() override
initialize
Definition: SpacePointAnalysisAlg.cxx:19
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
PixelID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: PixelID.h:619
ActsTrk::SpacePointAnalysisAlg::m_spacePointContainerKey
SG::ReadHandleKey< xAOD::SpacePointContainer > m_spacePointContainerKey
Definition: SpacePointAnalysisAlg.h:33
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
SpacePointAnalysisAlg.h
xAOD::SpacePoint_v1
Definition: SpacePoint_v1.h:29
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
SCT_ID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: SCT_ID.h:728
SCT_ID::phi_module
int phi_module(const Identifier &id) const
Definition: SCT_ID.h:740
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
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
Monitored::Collection
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
Definition: MonitoredCollection.h:38
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition: StoreGate/StoreGate/ReadDecorHandle.h:94
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
ActsTrk::SpacePointAnalysisAlg::m_usePixel
Gaudi::Property< bool > m_usePixel
Definition: SpacePointAnalysisAlg.h:37
UncalibratedMeasurementContainer.h
DataVector::front
const T * front() const
Access the first element in the collection as an rvalue.
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthMonitorAlgorithm::fill
void fill(const ToolHandle< GenericMonitoringTool > &groupHandle, std::vector< std::reference_wrapper< Monitored::IMonitoredVariable >> &&variables) const
Fills a vector of variables to a group by reference.
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
ActsTrk::SpacePointAnalysisAlg::m_clusterDecoration
SG::ReadDecorHandleKey< xAOD::SpacePointContainer > m_clusterDecoration
Definition: SpacePointAnalysisAlg.h:34
PixelID::layer_disk
int layer_disk(const Identifier &id) const
Definition: PixelID.h:626
PixelID::eta_module
int eta_module(const Identifier &id) const
Definition: PixelID.h:651
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
ActsTrk::SpacePointAnalysisAlg::SpacePointAnalysisAlg
SpacePointAnalysisAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: SpacePointAnalysisAlg.cxx:15
SCT_ID::layer_disk
int layer_disk(const Identifier &id) const
Definition: SCT_ID.h:734
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
ContainerAccessor.h
xAOD::SpacePointContainer
SpacePointContainer_v1 SpacePointContainer
Define the version of the space point container.
Definition: Event/xAOD/xAODInDetMeasurement/xAODInDetMeasurement/SpacePointContainer.h:14
SCT_ID
Definition: SCT_ID.h:68
ActsTrk::SpacePointAnalysisAlg::m_useOverlap
Gaudi::Property< bool > m_useOverlap
Definition: SpacePointAnalysisAlg.h:38
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
ReadDecorHandle.h
Handle class for reading a decoration on an object.
SG::ConstAccessor::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MuonDetectorBuilderTool.cxx:54
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
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
PixelID::phi_module
int phi_module(const Identifier &id) const
Definition: PixelID.h:644
PixelID
Definition: PixelID.h:67
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
ActsTrk::SpacePointAnalysisAlg::m_monGroupName
Gaudi::Property< std::string > m_monGroupName
Definition: SpacePointAnalysisAlg.h:36
Identifier
Definition: IdentifierFieldParser.cxx:14