ATLAS Offline Software
Loading...
Searching...
No Matches
MDTDigitVariables.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
5
9namespace MuonPRDTest {
10 MdtDigitVariables::MdtDigitVariables(MuonTesterTree& tree, const std::string& container_name, MSG::Level msglvl) :
11 PrdTesterModule(tree, "Digits_MDT", msglvl), m_digitKey{container_name} {}
12
13 bool MdtDigitVariables::fill(const EventContext& ctx) {
14 ATH_MSG_DEBUG("do fill Mdt digit variables ");
15 const MuonGM::MuonDetectorManager* MuonDetMgr = getDetMgr(ctx);
16 if (!MuonDetMgr) { return false; }
18 if (!MdtDigitContainer.isValid()) {
19 ATH_MSG_FATAL("Failed to retrieve digit container " << m_digitKey.fullKey());
20 return false;
21 }
22 ATH_MSG_DEBUG("retrieved MDT Digit Container with size " << MdtDigitContainer->digit_size());
23
24 if (MdtDigitContainer->size() == 0) ATH_MSG_DEBUG(" MDT Digit Container empty ");
25 unsigned int n_digits{0};
26
27 for (const MdtDigitCollection* coll : *MdtDigitContainer) {
28 ATH_MSG_DEBUG("processing collection with size " << coll->size());
29 for (unsigned int digitNum = 0; digitNum < coll->size(); ++digitNum) {
30 const MdtDigit* digit = coll->at(digitNum);
31
32 Identifier Id = digit->identify();
33 const MuonGM::MdtReadoutElement* rdoEl = MuonDetMgr->getMdtReadoutElement(Id);
34 if (!rdoEl) {
35 ATH_MSG_ERROR("MDTDigitVariables::fillVariables() - Failed to retrieve MDTReadoutElement for "<<idHelperSvc()->mdtIdHelper().print_to_string(Id).c_str());
36 return false;
37 }
38
39 const Identifier first_ml = idHelperSvc()->mdtIdHelper().channelID(
40 idHelperSvc()->stationName(Id), idHelperSvc()->stationEta(Id), idHelperSvc()->stationPhi(Id), 1, 1, 1);
41 const MuonGM::MdtReadoutElement* firstEl = MuonDetMgr->getMdtReadoutElement(first_ml);
42
43 int NofMultilayers = idHelperSvc()->mdtIdHelper().numberOfMultilayers(Id);
44
45 ATH_MSG_DEBUG("MDT Digit Offline id: " << idHelperSvc()->toString(Id));
46
47 m_MDT_digit_id.push_back(Id);
48 m_MDT_dig_time.push_back(digit->tdc());
49 m_MDT_dig_charge.push_back(digit->adc());
50
52 const Amg::Vector3D globalpos = rdoEl->tubePos(Id);
54 const Amg::Vector3D localTubePos = firstEl->transform().inverse() * globalpos;
55
56 m_MDT_dig_globalPos.push_back(globalpos);
57 m_MDT_dig_localTubePos.push_back(localTubePos);
58 m_MDT_dig_numberOfMultilayers.push_back(NofMultilayers);
59 ++n_digits;
60 }
61 }
62 m_MDT_nDigits = n_digits;
63 ATH_MSG_DEBUG(" finished fillMdtDigitVariables()");
64 return true;
65 }
67} // namespace MuonPRDTest
#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.
Use IdentifiableContainer with MdtDigitCollection.
size_type digit_size() const
int numberOfMultilayers(const Identifier &id) const
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int tubeLayer, int tube) const
Amg::Vector3D tubePos(const Identifier &id) const
Returns the global position of the given tube.
virtual const Amg::Transform3D & transform(const Identifier &id) const override final
Return local to global transform associated with this identifier.
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
const MdtReadoutElement * getMdtReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
MdtDigitVariables(MuonTesterTree &tree, const std::string &container_name, MSG::Level msglvl)
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_dig_time
SG::ReadHandleKey< MdtDigitContainer > m_digitKey
VectorBranch< float > & m_MDT_dig_charge
ScalarBranch< int > & m_MDT_nDigits
ThreeVectorBranch m_MDT_dig_localTubePos
VectorBranch< int > & m_MDT_dig_numberOfMultilayers
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 const MdtIdHelper & mdtIdHelper() const =0
access to MdtIdHelper
Eigen::Matrix< double, 3, 1 > Vector3D