ATLAS Offline Software
Loading...
Searching...
No Matches
CSCDigitVariables.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
8namespace MuonPRDTest {
9 CscDigitVariables::CscDigitVariables(MuonTesterTree& tree, const std::string& container_name, MSG::Level msglvl) :
10 PrdTesterModule(tree, "Digits_CSC", msglvl), m_key{container_name} {}
12
13 bool CscDigitVariables::fill(const EventContext& ctx) {
14 ATH_MSG_DEBUG("do fillCSCDigitVariables()");
15 const MuonGM::MuonDetectorManager* MuonDetMgr = getDetMgr(ctx);
16 if (!MuonDetMgr) { return false; }
18 if (!CscDigitContainer.isValid()) {
19 ATH_MSG_FATAL("Failed to retrieve digit container " << m_key.fullKey());
20 return false;
21 }
22
23 ATH_MSG_DEBUG("retrieved CSC Digit Container with size " << CscDigitContainer->digit_size());
24
25 if (CscDigitContainer->size() == 0) ATH_MSG_DEBUG(" CSC Digit Container empty ");
26 unsigned int n_digits{0};
27 for (const CscDigitCollection* coll : *CscDigitContainer) {
28 ATH_MSG_DEBUG("processing collection with size " << coll->size());
29 for (unsigned int digitNum = 0; digitNum < coll->size(); digitNum++) {
30 const CscDigit* digit = coll->at(digitNum);
31
32 Identifier Id = digit->identify();
33 ATH_MSG_DEBUG("CSC Digit Offline id: " << idHelperSvc()->toString(Id));
34
35 const MuonGM::CscReadoutElement* rdoEl = MuonDetMgr->getCscReadoutElement(Id);
36 if (!rdoEl) {
37 ATH_MSG_ERROR("CSCDigitVariables::fillVariables() - Failed to retrieve CSCReadoutElement for "<<idHelperSvc()->cscIdHelper().print_to_string(Id).c_str());
38 return false;
39 }
40
41 Amg::Vector3D gpos{0., 0., 0.};
42 Amg::Vector2D lpos(0., 0.);
43
44 rdoEl->surface(Id).localToGlobal(lpos, gpos, gpos);
45 m_CSC_dig_globalPos.push_back(gpos);
46 m_CSC_dig_id.push_back(Id);
47
48 ++n_digits;
49 }
50 // Local digit position information loss after localToGlobal transformation, fill the local positions in another loop for retrieving the local positions
51 for (unsigned int digitNum = 0; digitNum < coll->size(); digitNum++) {
52 const CscDigit* digit = coll->at(digitNum);
53 Identifier Id = digit->identify();
54 ATH_MSG_DEBUG("CSC Digit Offline id: " << idHelperSvc()->toString(Id));
55
56 const MuonGM::CscReadoutElement* rdoEl = MuonDetMgr->getCscReadoutElement(Id);
57 if (!rdoEl) return false;
58
59 Amg::Vector3D glpos{0., 0., 0.};
60 Amg::Vector2D lopos(0., 0.);
61
62 rdoEl->surface(Id).globalToLocal(glpos, glpos, lopos);
63 m_CSC_dig_localPosX.push_back(lopos.x());
64 m_CSC_dig_localPosX.push_back(lopos.y());
65 }
66 }
67 m_CSC_nDigits = n_digits;
68 ATH_MSG_DEBUG(" finished fillCscDigitVariables()");
69 return true;
70 }
71}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_DEBUG(x)
Use IdentifiableContainer with CscDigitCollection.
size_type digit_size() const
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 CscReadoutElement * getCscReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
VectorBranch< float > & m_CSC_dig_localPosX
SG::ReadHandleKey< CscDigitContainer > m_key
CscDigitVariables(MuonTesterTree &tree, const std::string &container_name, MSG::Level msglvl)
ScalarBranch< unsigned int > & m_CSC_nDigits
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...
const MuonGM::MuonDetectorManager * getDetMgr(const EventContext &ctx) const
const Muon::IMuonIdHelperSvc * idHelperSvc() const
PrdTesterModule(MuonTesterTree &tree, const std::string &grp_name, MSG::Level msglvl)
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.
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