ATLAS Offline Software
HgtdClusterAnalysisAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 
9 namespace ActsTrk {
10 
11  HgtdClusterAnalysisAlg::HgtdClusterAnalysisAlg(const std::string& name, ISvcLocator *pSvcLocator)
12  : AthMonitorAlgorithm(name, pSvcLocator)
13  {}
14 
16  ATH_MSG_DEBUG( "Initializing " << name() << " ... " );
17 
18  ATH_CHECK( m_hgtdClusterContainerKey.initialize() );
20  ATH_CHECK(detStore()->retrieve(m_hgtdID,"HGTD_ID"));
21 
22  ATH_MSG_DEBUG("Monitoring settings ...");
24 
26  }
27 
28  StatusCode HgtdClusterAnalysisAlg::fillHistograms(const EventContext& ctx) const {
29  ATH_MSG_DEBUG( "In " << name() << "::fillHistograms()" );
30 
32  const InDetDD::HGTD_DetectorElementCollection* hgtdElements(*hgtdDetEleHandle);
33  if (not hgtdDetEleHandle.isValid() or hgtdElements==nullptr) {
34  ATH_MSG_FATAL(m_HGTDDetEleCollKey.fullKey() << " is not available.");
35  return StatusCode::FAILURE;
36  }
37 
39  if (not inputHgtdClusterContainer.isValid()){
40  ATH_MSG_FATAL("xAOD::HGTDClusterContainer with key " << m_hgtdClusterContainerKey.key() << " is not available...");
41  return StatusCode::FAILURE;
42  }
43  const xAOD::HGTDClusterContainer* hgtdClusterContainer = inputHgtdClusterContainer.cptr();
44 
45  // IDs variables, e.g. module, disk or any detector-related variable HGTD uses
46  // We can add global position here
47  // Variables like eta, perp
48 
49  std::vector<float> global_x (hgtdClusterContainer->size(), 0);
50  std::vector<float> global_y (hgtdClusterContainer->size(), 0);
51  std::vector<float> global_z (hgtdClusterContainer->size(), 0);
52  std::vector<float> global_r (hgtdClusterContainer->size(), 0);
53  std::vector<float> eta (hgtdClusterContainer->size(), 0);
54 
55  for (std::size_t i(0ul); i<hgtdClusterContainer->size(); ++i) {
56  const xAOD::HGTDCluster *cluster = hgtdClusterContainer->at(i);
57  const Identifier& id = m_hgtdID->wafer_id(cluster->identifierHash());
58  const auto *element = hgtdElements->getDetectorElement(m_hgtdID->wafer_hash(m_hgtdID->wafer_id(id)));
59 
60  const Amg::Transform3D& T = element->surface().transform();
61  double Ax[3] = {T(0,0),T(1,0),T(2,0)};
62  double Ay[3] = {T(0,1),T(1,1),T(2,1)};
63  double R [3] = {T(0,3),T(1,3),T(2,3)};
64 
65  const auto& local_position = cluster->template localPosition<3>();
66  Amg::Vector2D M;
67  M[0] = local_position(0,0);
68  M[1] = local_position(1,0);
69  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]);
70 
71  global_x[i] = globalPos.x();
72  global_y[i] = globalPos.y();
73  global_z[i] = globalPos.z();
74  global_r[i] = std::sqrt(global_x[i]*global_x[i] + global_y[i]*global_y[i]);
75  eta[i] = globalPos.eta();
76  }
77 
78  // Local Position
79  auto monitor_localX = Monitored::Collection("localX", *inputHgtdClusterContainer,
80  [] (const auto cluster) -> float
81  {
82  const auto& localPos = cluster->template localPosition<3>();
83  return localPos(0,0);
84  });
85  auto monitor_localY = Monitored::Collection("localY", *inputHgtdClusterContainer,
86  [] (const auto cluster) -> float
87  {
88  const auto& localPos = cluster->template localPosition<3>();
89  return localPos(1,0);
90  });
91 
92  auto monitor_localT = Monitored::Collection("localT", *inputHgtdClusterContainer,
93  [] (const auto cluster) -> float
94  {
95  const auto& localPos = cluster->template localPosition<3>();
96  return localPos(2,0);
97  });
98 
99  // Local Covariance
100  auto monitor_localCovXX = Monitored::Collection("localCovXX", *inputHgtdClusterContainer,
101  [] (const auto* cluster) -> float
102  { return cluster->template localCovariance<3>()(0, 0); });
103  auto monitor_localCovYY = Monitored::Collection("localCovYY", *inputHgtdClusterContainer,
104  [] (const auto* cluster) -> float
105  { return cluster->template localCovariance<3>()(1, 1); });
106 
107  auto monitor_localCovTT = Monitored::Collection("localCovTT", *inputHgtdClusterContainer,
108  [] (const auto* cluster) -> float
109  { return cluster->template localCovariance<3>()(2, 2); });
110 
111  auto monitor_globalX = Monitored::Collection("globalX", global_x);
112  auto monitor_globalY = Monitored::Collection("globalY", global_y);
113  auto monitor_globalZ = Monitored::Collection("globalZ", global_z);
114  auto monitor_globalR = Monitored::Collection("globalR", global_r);
115  auto monitor_eta = Monitored::Collection("eta", eta);
116 
117  fill(m_monGroupName.value(),
118  monitor_localX, monitor_localY, monitor_localT,
119  monitor_localCovXX, monitor_localCovYY, monitor_localCovTT,
120  monitor_globalX, monitor_globalY, monitor_globalZ, monitor_globalR,
121  monitor_eta);
122  return StatusCode::SUCCESS;
123  }
124 
125 }
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:15
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.
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:206
xAOD::HGTDCluster_v1
Definition: HGTDCluster_v1.h:23
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:11
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:28
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?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
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: MuonDetectorBuilderTool.cxx:54
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
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.
Identifier
Definition: IdentifierFieldParser.cxx:14