ATLAS Offline Software
Loading...
Searching...
No Matches
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
9
10namespace ActsTrk {
11
12 HgtdClusterAnalysisAlg::HgtdClusterAnalysisAlg(const std::string& name, ISvcLocator *pSvcLocator)
13 : AthMonitorAlgorithm(name, pSvcLocator)
14 {}
15
17 ATH_MSG_DEBUG( "Initializing " << name() << " ... " );
18
20 ATH_CHECK( m_HGTDDetEleCollKey.initialize() );
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>();
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}
Scalar eta() const
pseudorapidity method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_DEBUG(x)
Header file to be included by clients of the Monitored infrastructure.
virtual StatusCode initialize() override
initialize
SG::ReadHandleKey< xAOD::HGTDClusterContainer > m_hgtdClusterContainerKey
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Gaudi::Property< std::string > m_monGroupName
HgtdClusterAnalysisAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadCondHandleKey< InDetDD::HGTD_DetectorElementCollection > m_HGTDDetEleCollKey
const ServiceHandle< StoreGateSvc > & detStore() const
virtual StatusCode initialize() override
initialize
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
const T * at(size_type n) const
Access an element, as an rvalue.
size_type size() const noexcept
Returns the number of elements in the collection.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
DetectorIDHashType identifierHash() const
Returns the IdentifierHash of the measurement (corresponds to the detector element IdentifierHash)
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.
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
const HGTD_DetectorElement * getDetectorElement(const IdentifierHash &hash, const HGTD_DetectorElementCollection &coll)
DataVector< HGTD_DetectorElement > HGTD_DetectorElementCollection
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
HGTDClusterContainer_v1 HGTDClusterContainer
Define the version of the HGTD cluster container.
HGTDCluster_v1 HGTDCluster
Define the version of the pixel cluster class.
Definition HGTDCluster.h:13