ATLAS Offline Software
Loading...
Searching...
No Matches
sTGCDigitVariables.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
8
9namespace MuonPRDTest {
10 sTgcDigitVariables::sTgcDigitVariables(MuonTesterTree& tree, const std::string& container_name, MSG::Level msglvl) :
11 PrdTesterModule(tree, "Digits_sTGC", msglvl), m_key{container_name} {}
12
14 bool sTgcDigitVariables::fill(const EventContext& ctx) {
15 ATH_MSG_DEBUG("do fillsTGCDigitHitVariables()");
16 const MuonGM::MuonDetectorManager* MuonDetMgr = getDetMgr(ctx);
17 if (!MuonDetMgr) { return false; }
19 if (!sTgcDigitContainer.isValid()) {
20 ATH_MSG_FATAL("Failed to retrieve digit container " << m_key.fullKey());
21 return false;
22 }
23
24 ATH_MSG_DEBUG("retrieved sTGC Digit Container with size " << sTgcDigitContainer->digit_size());
25
26 if (sTgcDigitContainer->size() == 0) ATH_MSG_DEBUG(" sTGC Digit Container empty ");
27 unsigned int n_digits{0};
28 for (const sTgcDigitCollection* coll : *sTgcDigitContainer) {
29 ATH_MSG_DEBUG("processing collection with size " << coll->size());
30 for (unsigned int digitNum = 0; digitNum < coll->size(); digitNum++) {
31 const sTgcDigit* digit = coll->at(digitNum);
32 Identifier Id = digit->identify();
33
34 const MuonGM::sTgcReadoutElement* rdoEl = MuonDetMgr->getsTgcReadoutElement(Id);
35 if (!rdoEl) {
36 ATH_MSG_ERROR("sTGCDigitVariables::fillVariables() - Failed to retrieve sTGCReadoutElement for "<<idHelperSvc()->toString(Id));
37 return false;
38 }
39 m_NSWsTGC_dig_id.push_back(Id);
40 Amg::Vector3D gpos{Amg::Vector3D::Zero()};
41 Amg::Vector2D lpos(Amg::Vector2D::Zero());
42
43 rdoEl->stripPosition(Id, lpos);
44 rdoEl->surface(Id).localToGlobal(lpos, gpos, gpos);
45
46 m_NSWsTGC_dig_globalPos.push_back(gpos);
47 m_NSWsTGC_dig_localPos.push_back(lpos);
48
49 m_NSWsTGC_dig_channelNumber.push_back(rdoEl->stripNumber(lpos, Id));
50 if(idHelperSvc()->stgcIdHelper().channelType(Id) == sTgcIdHelper::Pad ) {
51
52 std::array<Amg::Vector2D, 4> local_pad_corners{make_array<Amg::Vector2D, 4>(Amg::Vector2D::Zero())};
53 rdoEl->padCorners(Id,local_pad_corners);
54
55 for(const Amg::Vector2D& local_corner : local_pad_corners) {
56 Amg::Vector3D global_corner{Amg::Vector3D::Zero()};
57 rdoEl->surface(Id).localToGlobal(local_corner, global_corner, global_corner);
58 m_NSWsTGC_dig_PadglobalCornerPos.push_back(global_corner);
59 }
60 }
61
62 m_NSWsTGC_dig_bctag.push_back(digit->bcTag());
63 m_NSWsTGC_dig_time.push_back(digit->time());
64 m_NSWsTGC_dig_charge.push_back(digit->charge());
65 m_NSWsTGC_dig_isDead.push_back(digit->isDead());
66 m_NSWsTGC_dig_isPileup.push_back(digit->isPileup());
67
68 ++n_digits;
69 }
70 }
71 m_NSWsTGC_nDigits = n_digits;
72 ATH_MSG_DEBUG(" finished fillsTgcDigitVariables()");
73 return true;
74 }
75}
constexpr std::array< T, N > make_array(const T &def_val)
Helper function to initialize in-place arrays with non-zero values.
Definition ArrayHelper.h:10
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_DEBUG(x)
size_t size() const
Duplicate of fullSize for backwards compatability.
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...
virtual bool stripPosition(const Identifier &id, Amg::Vector2D &pos) const override final
strip position - should be renamed to channel position If the strip number is outside the range of va...
bool padCorners(const Identifier &id, std::array< Amg::Vector2D, 4 > &corners) const
pad corners
virtual int stripNumber(const Amg::Vector2D &pos, const Identifier &id) const override final
strip number corresponding to local position.
const MuonGM::MuonDetectorManager * getDetMgr(const EventContext &ctx) const
const Muon::IMuonIdHelperSvc * idHelperSvc() const
PrdTesterModule(MuonTesterTree &tree, const std::string &grp_name, MSG::Level msglvl)
VectorBranch< int > & m_NSWsTGC_dig_bctag
SG::ReadHandleKey< sTgcDigitContainer > m_key
sTgcIdentifierBranch m_NSWsTGC_dig_id
VectorBranch< bool > & m_NSWsTGC_dig_isDead
sTgcDigitVariables(MuonTesterTree &tree, const std::string &container_name, MSG::Level msglvl)
ScalarBranch< unsigned int > & m_NSWsTGC_nDigits
VectorBranch< double > & m_NSWsTGC_dig_time
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< int > & m_NSWsTGC_dig_channelNumber
VectorBranch< double > & m_NSWsTGC_dig_charge
ThreeVectorBranch m_NSWsTGC_dig_PadglobalCornerPos
VectorBranch< bool > & m_NSWsTGC_dig_isPileup
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 void localToGlobal(const Amg::Vector2D &locp, const Amg::Vector3D &mom, Amg::Vector3D &glob) const override final
Specified for PlaneSurface: LocalToGlobal method without dynamic memory allocation.
Use IdentifiableContainer with sTgcDigitCollection.
size_type digit_size() const
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D