ATLAS Offline Software
Loading...
Searching...
No Matches
sTGCSDOVariables.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
7
8namespace MuonPRDTest {
9 sTgcSDOVariables::sTgcSDOVariables(MuonTesterTree& tree, const std::string& container_name, MSG::Level msglvl) :
10 PrdTesterModule(tree, "SDO_sTGC", msglvl), m_key{container_name} {}
11
13
14 bool sTgcSDOVariables::fill(const EventContext& ctx) {
15 ATH_MSG_DEBUG("do fill sTgcSDOVariables()");
16 SG::ReadHandle<MuonSimDataCollection> stgcSdoContainer{m_key, ctx};
17 if (!stgcSdoContainer.isValid()) {
18 ATH_MSG_FATAL("Failed to retrieve digit container " << m_key.fullKey());
19 return false;
20 }
21 const MuonGM::MuonDetectorManager* MuonDetMgr = getDetMgr(ctx);
22 if (!MuonDetMgr) { return false; }
23 unsigned int n_sdo{0};
24 for (const auto& coll : *stgcSdoContainer) {
25 const Identifier& id = coll.first;
26 const MuonSimData& stgc_sdo = coll.second;
27
28 m_NSWsTGC_sdo_globaltime.push_back(stgc_sdo.getTime());
29 m_NSWsTGC_sdo_word.push_back(stgc_sdo.word());
30
31 ATH_MSG_DEBUG("sTGC SDO: " << idHelperSvc()->toString(id));
32
33 ATH_MSG_DEBUG("Get the truth deposits from the SDO.");
34 std::vector<MuonSimData::Deposit> deposits;
35 stgc_sdo.deposits(deposits);
36
37 const Amg::Vector3D hit_gpos = stgc_sdo.globalPosition();
38 m_NSWsTGC_dig_globalPos.push_back(hit_gpos);
39
40 // use the information of the first deposit
41 int barcode = deposits[0].first.barcode();
42 double MuonMCdata_firstentry = deposits[0].second.firstEntry();
43 double MuonMCdata_secondentry = deposits[0].second.secondEntry();
44
45 ATH_MSG_DEBUG("sTGC SDO barcode=" << barcode);
46 ATH_MSG_DEBUG("sTGC SDO energy=" << std::setw(9) << std::setprecision(2) << MuonMCdata_firstentry
47 << ", tof=" << std::setw(9) << std::setprecision(2) << MuonMCdata_secondentry);
48
49 m_NSWsTGC_sdo_barcode.push_back(barcode);
50 m_NSWsTGC_sdo_E.push_back(MuonMCdata_firstentry);
51 m_NSWsTGC_sdo_tof.push_back(MuonMCdata_secondentry);
52
53 // Retrieve the detector element and local SDO coordinates
54 const MuonGM::sTgcReadoutElement* rdoEl = MuonDetMgr->getsTgcReadoutElement(id);
55 if (!rdoEl) {
56 ATH_MSG_ERROR("sTGCSDOVariables::fillVariables() - Failed to retrieve sTgcReadoutElement for " << idHelperSvc()->toString(id));
57 return false;
58 }
59
60 m_NSWsTGC_sdo_id.push_back(id);
61 Amg::Vector2D loc_pos(0., 0.);
62 rdoEl->surface(id).globalToLocal(stgc_sdo.globalPosition(), Amg::Vector3D(0., 0., 0.), loc_pos);
63 ATH_MSG_DEBUG("sTGC SDO local position X=" << std::setw(9) << std::setprecision(2) << loc_pos[0]
64 << ", local position Y=" << std::setw(9) << std::setprecision(2) << loc_pos[1]);
65 m_NSWsTGC_sdo_localPosX.push_back( loc_pos[0] );
66 m_NSWsTGC_sdo_localPosY.push_back( loc_pos[1] );
67
68 ++n_sdo;
69 }
70 m_NSWsTGC_nsdo = n_sdo;
71
72 ATH_MSG_DEBUG("Processed " << n_sdo << " sTGC SDOs");
73 return true;
74 }
75}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_DEBUG(x)
virtual const Trk::PlaneSurface & surface() const override
access to chamber surface (phi orientation), uses the first gas gap
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
const sTgcReadoutElement * getsTgcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
An sTgcReadoutElement corresponds to a single STGC module; therefore typicaly a barrel muon station c...
const MuonGM::MuonDetectorManager * getDetMgr(const EventContext &ctx) const
const Muon::IMuonIdHelperSvc * idHelperSvc() const
PrdTesterModule(MuonTesterTree &tree, const std::string &grp_name, MSG::Level msglvl)
sTgcIdentifierBranch m_NSWsTGC_sdo_id
bool declare_keys() override final
SG::ReadHandleKey< MuonSimDataCollection > m_key
ThreeVectorBranch m_NSWsTGC_dig_globalPos
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_NSWsTGC_sdo_globaltime
ScalarBranch< unsigned int > & m_NSWsTGC_nsdo
VectorBranch< int > & m_NSWsTGC_sdo_word
VectorBranch< float > & m_NSWsTGC_sdo_tof
VectorBranch< float > & m_NSWsTGC_sdo_E
VectorBranch< float > & m_NSWsTGC_sdo_localPosX
sTgcSDOVariables(MuonTesterTree &tree, const std::string &container_name, MSG::Level msglvl)
VectorBranch< int > & m_NSWsTGC_sdo_barcode
VectorBranch< float > & m_NSWsTGC_sdo_localPosY
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?
virtual bool globalToLocal(const Amg::Vector3D &glob, const Amg::Vector3D &mom, Amg::Vector2D &loc) const override final
Specified for PlaneSurface: GlobalToLocal method without dynamic memory allocation - boolean checks i...
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D