ATLAS Offline Software
HgtdClusterAnalysisAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 #include "TrkSurfaces/Surface.h"
9 
10 namespace ActsTrk {
11 
12  HgtdClusterAnalysisAlg::HgtdClusterAnalysisAlg(const std::string& name, ISvcLocator *pSvcLocator)
13  : AthMonitorAlgorithm(name, pSvcLocator)
14  {}
15 
17  ATH_MSG_DEBUG( "Initializing " << name() << " ... " );
18 
21  ATH_CHECK(detStore()->retrieve(m_hgtdID,"HGTD_ID"));
22 
23  ATH_MSG_DEBUG("Monitoring settings ...");
25 
27  }
28 
29  StatusCode HgtdClusterAnalysisAlg::fillHistograms(const EventContext& ctx) const {
30  ATH_MSG_DEBUG( "In " << name() << "::fillHistograms()" );
31 
33  const InDetDD::HGTD_DetectorElementCollection* hgtdElements(*hgtdDetEleHandle);
34  if (not hgtdDetEleHandle.isValid() or hgtdElements==nullptr) {
35  ATH_MSG_FATAL(m_HGTDDetEleCollKey.fullKey() << " is not available.");
36  return StatusCode::FAILURE;
37  }
38 
40  if (not inputHgtdClusterContainer.isValid()){
41  ATH_MSG_FATAL("xAOD::HGTDClusterContainer with key " << m_hgtdClusterContainerKey.key() << " is not available...");
42  return StatusCode::FAILURE;
43  }
44  const xAOD::HGTDClusterContainer* hgtdClusterContainer = inputHgtdClusterContainer.cptr();
45 
46  // IDs variables, e.g. module, disk or any detector-related variable HGTD uses
47  // We can add global position here
48  // Variables like eta, perp
49 
50  std::vector<float> global_x (hgtdClusterContainer->size(), 0);
51  std::vector<float> global_y (hgtdClusterContainer->size(), 0);
52  std::vector<float> global_z (hgtdClusterContainer->size(), 0);
53  std::vector<float> global_r (hgtdClusterContainer->size(), 0);
54  std::vector<float> eta (hgtdClusterContainer->size(), 0);
55 
56  for (std::size_t i(0ul); i<hgtdClusterContainer->size(); ++i) {
57  const xAOD::HGTDCluster *cluster = hgtdClusterContainer->at(i);
58  const Identifier& id = m_hgtdID->wafer_id(cluster->identifierHash());
59  const auto *element = InDetDD::HGTDDetEl::getDetectorElement(m_hgtdID->wafer_hash(m_hgtdID->wafer_id(id)),*hgtdElements);
60 
61  const Amg::Transform3D& T = element->surface().transform();
62  double Ax[3] = {T(0,0),T(1,0),T(2,0)};
63  double Ay[3] = {T(0,1),T(1,1),T(2,1)};
64  double R [3] = {T(0,3),T(1,3),T(2,3)};
65 
66  const auto& local_position = cluster->template localPosition<3>();
67  Amg::Vector2D M;
68  M[0] = local_position(0,0);
69  M[1] = local_position(1,0);
70  Amg::Vector3D globalPos(M[0]*Ax[0]+M[1]*Ay[0]+R[0],M[0]*Ax[1]+M[1]*Ay[1]+R[1],M[0]*Ax[2]+M[1]*Ay[2]+R[2]);
71 
72  global_x[i] = globalPos.x();
73  global_y[i] = globalPos.y();
74  global_z[i] = globalPos.z();
75  global_r[i] = std::sqrt(global_x[i]*global_x[i] + global_y[i]*global_y[i]);
76  eta[i] = globalPos.eta();
77  }
78 
79  // Local Position
80  auto monitor_localX = Monitored::Collection("localX", *inputHgtdClusterContainer,
81  [] (const auto cluster) -> float
82  {
83  const auto& localPos = cluster->template localPosition<3>();
84  return localPos(0,0);
85  });
86  auto monitor_localY = Monitored::Collection("localY", *inputHgtdClusterContainer,
87  [] (const auto cluster) -> float
88  {
89  const auto& localPos = cluster->template localPosition<3>();
90  return localPos(1,0);
91  });
92 
93  auto monitor_localT = Monitored::Collection("localT", *inputHgtdClusterContainer,
94  [] (const auto cluster) -> float
95  {
96  const auto& localPos = cluster->template localPosition<3>();
97  return localPos(2,0);
98  });
99 
100  // Local Covariance
101  auto monitor_localCovXX = Monitored::Collection("localCovXX", *inputHgtdClusterContainer,
102  [] (const auto* cluster) -> float
103  { return cluster->template localCovariance<3>()(0, 0); });
104  auto monitor_localCovYY = Monitored::Collection("localCovYY", *inputHgtdClusterContainer,
105  [] (const auto* cluster) -> float
106  { return cluster->template localCovariance<3>()(1, 1); });
107 
108  auto monitor_localCovTT = Monitored::Collection("localCovTT", *inputHgtdClusterContainer,
109  [] (const auto* cluster) -> float
110  { return cluster->template localCovariance<3>()(2, 2); });
111 
112  auto monitor_globalX = Monitored::Collection("globalX", global_x);
113  auto monitor_globalY = Monitored::Collection("globalY", global_y);
114  auto monitor_globalZ = Monitored::Collection("globalZ", global_z);
115  auto monitor_globalR = Monitored::Collection("globalR", global_r);
116  auto monitor_eta = Monitored::Collection("eta", eta);
117 
118  fill(m_monGroupName.value(),
119  monitor_localX, monitor_localY, monitor_localT,
120  monitor_localCovXX, monitor_localCovYY, monitor_localCovTT,
121  monitor_globalX, monitor_globalY, monitor_globalZ, monitor_globalR,
122  monitor_eta);
123  return StatusCode::SUCCESS;
124  }
125 
126 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::UncalibratedMeasurement_v1::identifierHash
DetectorIDHashType identifierHash() const
Returns the IdentifierHash of the measurement (corresponds to the detector element IdentifierHash)
ActsTrk::HgtdClusterAnalysisAlg::initialize
virtual StatusCode initialize() override
initialize
Definition: HgtdClusterAnalysisAlg.cxx:16
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
HgtdClusterAnalysisAlg.h
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
HGTD_ID::wafer_hash
IdentifierHash wafer_hash(Identifier wafer_id) const
wafer hash from id
Definition: HGTD_ID.h:404
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
Surface.h
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:210
xAOD::HGTDCluster_v1
Definition: HGTDCluster_v1.h:23
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
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
Monitored::Collection
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
Definition: MonitoredCollection.h:38
ActsTrk::HgtdClusterAnalysisAlg::m_monGroupName
Gaudi::Property< std::string > m_monGroupName
Definition: HgtdClusterAnalysisAlg.h:35
ActsTrk::HgtdClusterAnalysisAlg::m_hgtdID
const HGTD_ID * m_hgtdID
Definition: HgtdClusterAnalysisAlg.h:37
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
ActsTrk::HgtdClusterAnalysisAlg::HgtdClusterAnalysisAlg
HgtdClusterAnalysisAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: HgtdClusterAnalysisAlg.cxx:12
ActsTrk::HgtdClusterAnalysisAlg::m_hgtdClusterContainerKey
SG::ReadHandleKey< xAOD::HGTDClusterContainer > m_hgtdClusterContainerKey
Definition: HgtdClusterAnalysisAlg.h:31
lumiFormat.i
int i
Definition: lumiFormat.py:85
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
HGTD_DetectorElement.h
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
detail::ul
unsigned long ul
Definition: PrimitiveHelpers.h:46
ActsTrk::HgtdClusterAnalysisAlg::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: HgtdClusterAnalysisAlg.cxx:29
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.
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
DataVector< HGTD_DetectorElement >
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?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
ActsTrk::HgtdClusterAnalysisAlg::m_HGTDDetEleCollKey
SG::ReadCondHandleKey< InDetDD::HGTD_DetectorElementCollection > m_HGTDDetEleCollKey
Definition: HgtdClusterAnalysisAlg.h:27
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MdtCalibInput.h:31
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
InDetDD::HGTDDetEl::getDetectorElement
const HGTD_DetectorElement * getDetectorElement(const IdentifierHash &hash, const HGTD_DetectorElementCollection &coll)
Definition: HGTD_DetectorElementCollection.h:25
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
Identifier
Definition: IdentifierFieldParser.cxx:14