ATLAS Offline Software
Loading...
Searching...
No Matches
MDTSDOVariables.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
7namespace MuonPRDTest {
8 MdtSDOVariables::MdtSDOVariables(MuonTesterTree& tree, const std::string& container_name, MSG::Level msglvl) :
9 PrdTesterModule(tree, "SDO_MDT", msglvl), m_sdo_key{container_name} {}
10
11 bool MdtSDOVariables::fill(const EventContext& ctx) {
12 const MuonGM::MuonDetectorManager* MuonDetMgr = getDetMgr(ctx);
13 if (!MuonDetMgr) { return false; }
14 ATH_MSG_DEBUG(" do fillMdtSDOVariables()");
15 ATH_MSG_VERBOSE("MuonDetectorManager from Conditions Store accessed" << MuonDetMgr);
16
17 ATH_MSG_DEBUG("Retrieve MDT SDO container with name = " << m_sdo_key.fullKey());
18
20 if (!mdtSdoContainer.isValid()) {
21 ATH_MSG_FATAL("Failed to retrieve SDO container " << m_sdo_key.fullKey());
22 return false;
23 }
24
25 for (const auto& coll : *mdtSdoContainer) {
26 const Identifier id = coll.first;
27 const MuonSimData& mdt_sdo = coll.second;
28 m_mdt_sdo_id.push_back(id);
29 // Get information on the SDO
30 ATH_MSG_DEBUG("MDT SDO: " << idHelperSvc()->toString(id));
31 ATH_MSG_DEBUG("Get the truth deposits from the SDO.");
32 std::vector<MuonSimData::Deposit> deposits;
33 mdt_sdo.deposits(deposits);
34
35 m_mdt_sdo_globalPos.push_back(mdt_sdo.globalPosition());
36 m_mdt_sdo_globalTime.push_back(mdt_sdo.getTime());
37 m_mdt_sdo_word.push_back(mdt_sdo.word());
38
39 // use the information of the first deposit
40 int barcode = deposits[0].first.barcode();
41 double MuonMCdata_firstentry = deposits[0].second.firstEntry();
42 double MuonMCdata_secondentry = deposits[0].second.secondEntry();
43
44 ATH_MSG_DEBUG("MDT SDO barcode=" << barcode);
45 ATH_MSG_DEBUG("MDT SDO localPosX=" << std::setw(9) << std::setprecision(2) << MuonMCdata_firstentry
46 << ", localPosY=" << std::setw(9) << std::setprecision(2) << MuonMCdata_secondentry);
47
48 m_mdt_sdo_barcode.push_back(barcode);
49 m_mdt_sdo_localPosX.push_back(MuonMCdata_firstentry);
50 m_mdt_sdo_localPosY.push_back(MuonMCdata_secondentry);
51 }
52 m_mdt_nsdo = mdtSdoContainer.cptr()->size();
53 ATH_MSG_DEBUG("Processed " << m_mdt_nsdo << " MDT SDOs");
54 return true;
55 }
56
58} // namespace MuonPRDTest
#define ATH_MSG_FATAL(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading from StoreGate.
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
VectorBranch< int > & m_mdt_sdo_word
SG::ReadHandleKey< MuonSimDataCollection > m_sdo_key
MdtIdentifierBranch m_mdt_sdo_id
VectorBranch< int > & m_mdt_sdo_barcode
ThreeVectorBranch m_mdt_sdo_globalPos
bool declare_keys() override final
MdtSDOVariables(MuonTesterTree &tree, const std::string &grp_name, MSG::Level msglvl)
VectorBranch< float > & m_mdt_sdo_localPosY
ScalarBranch< unsigned int > & m_mdt_nsdo
VectorBranch< float > & m_mdt_sdo_localPosX
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...
VectorBranch< float > & m_mdt_sdo_globalTime
const MuonGM::MuonDetectorManager * getDetMgr(const EventContext &ctx) const
const Muon::IMuonIdHelperSvc * idHelperSvc() const
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?
const_pointer_type cptr()
Dereference the pointer.