ATLAS Offline Software
Loading...
Searching...
No Matches
MMSDOVariables.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7namespace MuonPRDTest {
8 MMSDOVariables::MMSDOVariables(MuonTesterTree& tree, const std::string& container_name, MSG::Level msglvl) :
9 PrdTesterModule(tree, "SDO_MM", msglvl), m_key{container_name} {}
10
12
13 bool MMSDOVariables::fill(const EventContext& ctx) {
14 ATH_MSG_DEBUG("do fill MMSDOVariables()");
16 if (!mmSdoContainer.isValid()) {
17 ATH_MSG_FATAL("Failed to retrieve digit container " << m_key.fullKey());
18 return false;
19 }
20 unsigned int n_sdo{0};
21 for (const auto& coll : *mmSdoContainer) {
22 const Identifier& id = coll.first;
23 const MuonSimData& mm_sdo = coll.second;
24
25 m_NSWMM_sdo_globaltime.push_back(mm_sdo.getTime());
26 m_NSWMM_sdo_word.push_back(mm_sdo.word());
27
28 ATH_MSG_DEBUG("Get the truth deposits from the SDO.");
29 std::vector<MuonSimData::Deposit> deposits;
30 mm_sdo.deposits(deposits);
31
32 m_NSWMM_sdo_id.push_back(id);
33 const Amg::Vector3D hit_gpos = mm_sdo.globalPosition();
34 m_NSWMM_dig_globalPos.push_back(hit_gpos);
35
36 // use the information of the first deposit
37 int barcode = deposits[0].first.barcode();
38 double MuonMCdata_firstentry = deposits[0].second.firstEntry();
39 double MuonMCdata_secondentry = deposits[0].second.secondEntry();
40
41 ATH_MSG_DEBUG("MM SDO barcode=" << barcode);
42 ATH_MSG_DEBUG("MM SDO local position X=" << std::setw(9) << std::setprecision(2) << MuonMCdata_firstentry
43 << ", local position Y=" << std::setw(9) << std::setprecision(2) << MuonMCdata_secondentry);
44
45 m_NSWMM_sdo_barcode.push_back(barcode);
46
47 m_NSWMM_sdo_localPosX.push_back(MuonMCdata_firstentry);
48 m_NSWMM_sdo_localPosY.push_back(MuonMCdata_secondentry);
49
50 ++n_sdo;
51 }
52 m_NSWMM_nsdo = n_sdo;
53
54 ATH_MSG_DEBUG("Processed " << n_sdo << "MM SDOs");
55 return true;
56 }
57}
#define ATH_MSG_FATAL(x)
#define ATH_MSG_DEBUG(x)
bool fill(const EventContext &ctx) override final
The fill method checks if enough information is provided such that the branch is cleared from the inf...
ScalarBranch< unsigned int > & m_NSWMM_nsdo
VectorBranch< float > & m_NSWMM_sdo_localPosX
ThreeVectorBranch m_NSWMM_dig_globalPos
MmIdentifierBranch m_NSWMM_sdo_id
VectorBranch< int > & m_NSWMM_sdo_barcode
MMSDOVariables(MuonTesterTree &tree, const std::string &container_name, MSG::Level msglvl)
VectorBranch< float > & m_NSWMM_sdo_globaltime
bool declare_keys() override final
SG::ReadHandleKey< MuonSimDataCollection > m_key
VectorBranch< int > & m_NSWMM_sdo_word
VectorBranch< float > & m_NSWMM_sdo_localPosY
PrdTesterModule(MuonTesterTree &tree, const std::string &grp_name, MSG::Level msglvl)
int word() const
Definition MuonSimData.h:89
void deposits(std::vector< Deposit > &deposits) const
Definition MuonSimData.h:99
const Amg::Vector3D globalPosition() const
float getTime() const
bool declare_dependency(Key &key)
Declares the ReadHandle/ ReadCondHandleKey as data dependency of the algorithm.
TTree * tree() override final
Returns the underlying TTree object.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Eigen::Matrix< double, 3, 1 > Vector3D