ATLAS Offline Software
Loading...
Searching...
No Matches
CSCPRDVariables.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 CSCPRDVariables::CSCPRDVariables(MuonTesterTree& tree, const std::string& container_name, MSG::Level msglvl) :
11 PrdTesterModule(tree, "PRD_CSC", msglvl), m_key{container_name} {}
13
14 bool CSCPRDVariables::fill(const EventContext& ctx) {
15 ATH_MSG_DEBUG("do fillCSCPRDVariables()");
16 const MuonGM::MuonDetectorManager* MuonDetMgr = getDetMgr(ctx);
17 if (!MuonDetMgr) { return false; }
19 if (!cscprdContainer.isValid()) {
20 ATH_MSG_FATAL("Failed to retrieve prd container " << m_key.fullKey());
21 return false;
22 }
23
24 ATH_MSG_DEBUG("retrieved CSC PRD Container with size " << cscprdContainer->size());
25
26 if (cscprdContainer->size() == 0) ATH_MSG_DEBUG(" CSC PRD Container empty ");
27 unsigned int n_PRD{0};
28 for(auto it : *cscprdContainer ) {
29 const Muon::CscPrepDataCollection*coll = it;
30 for (auto prd: *coll) {
31 Identifier Id = prd->identify();
32
33 const MuonGM::CscReadoutElement* det = MuonDetMgr->getCscReadoutElement(Id);
34 if (!det) {
35 ATH_MSG_ERROR("The CSC hit "<<idHelperSvc()->toString(Id)<<" does not have a detector element attached. That should actually never happen");
36 return false;
37 }
38
39 m_CSC_PRD_id.push_back(Id);
40 m_CSC_PRD_charge.push_back(prd->charge());
41 m_CSC_PRD_time.push_back(prd->time());
42
43 Amg::Vector3D pos = prd->globalPosition();
44 Amg::Vector2D loc_pos(0., 0.);
45
46 det->surface(Id).globalToLocal(pos, Amg::Vector3D(0., 0., 0.), loc_pos);
47
48 m_CSC_PRD_globalPos.push_back(pos);
49
50 m_CSC_PRD_localPosX.push_back(loc_pos[0]);
51 m_CSC_PRD_localPosY.push_back(loc_pos[1]);
52
53 ++n_PRD;
54 }
55 }
56 m_CSC_nPRD = n_PRD;
57 ATH_MSG_DEBUG(" finished fillCSCPRDVariables()");
58 return true;
59 }
60}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_DEBUG(x)
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< int > & m_CSC_PRD_time
SG::ReadHandleKey< Muon::CscPrepDataContainer > m_key
CSCPRDVariables(MuonTesterTree &tree, const std::string &container_name, MSG::Level msglvl)
VectorBranch< float > & m_CSC_PRD_localPosY
ScalarBranch< unsigned int > & m_CSC_nPRD
bool declare_keys() override final
ThreeVectorBranch m_CSC_PRD_globalPos
VectorBranch< int > & m_CSC_PRD_charge
CscIdentifierBranch m_CSC_PRD_id
VectorBranch< float > & m_CSC_PRD_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...
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 bool isValid() override final
Can the handle be successfully dereferenced?
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
MuonPrepDataCollection< CscPrepData > CscPrepDataCollection