ATLAS Offline Software
Loading...
Searching...
No Matches
MMPRDVariables.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
9
10namespace MuonPRDTest {
11 MMPRDVariables::MMPRDVariables(MuonTesterTree& tree, const std::string& prd_container_name, MSG::Level msglvl) :
12 PrdTesterModule(tree, "PRD_MM", msglvl), m_key{prd_container_name} {}
13
15
16 bool MMPRDVariables::fill(const EventContext& ctx) {
17 m_externalPush = false;
18 ATH_MSG_DEBUG("do fillMMPRDVariables()");
20 if (!mmprdContainer.isValid()) {
21 ATH_MSG_FATAL("Failed to retrieve prd container " << m_key.fullKey());
22 return false;
23 }
24 ATH_MSG_DEBUG("retrieved MM PRD Container with size " << mmprdContainer->size());
25
26
27 unsigned int n_PRD{0};
28 for(const Muon::MMPrepDataCollection* coll : *mmprdContainer) {
29 if (m_applyFilter && !m_filteredChamb.count(coll->identify())) {
30 ATH_MSG_VERBOSE("Do not dump measurements from "<<idHelperSvc()->toStringChamber(coll->identify()));
31 continue;
32 }
33 for (const Muon::MMPrepData* prd : *coll) {
34 dump(*prd);
35 ++n_PRD;
36 }
37 }
38 m_NSWMM_nPRD = n_PRD;
39 ATH_MSG_DEBUG(" finished fillMMPRDVariables()");
40 m_filteredPRDs.clear();
41 m_filteredChamb.clear();
42 return true;
43 }
45 m_externalPush = true;
46 return dump(prd);
47 }
52 m_applyFilter = true;
53 m_filteredChamb.insert(idHelperSvc()->chamberId(detEle.identify()));
54 }
55
56 unsigned int MMPRDVariables::dump(const Muon::MMPrepData& prd) {
57 const Identifier Id = prd.identify();
58
59 if (m_filteredPRDs.count(Id)) {
60 ATH_MSG_VERBOSE("The hit has already been added "<<idHelperSvc()->toString(Id));
61 return m_filteredPRDs.at(Id);
62 }
63 m_NSWMM_PRD_time.push_back(prd.time());
64
66
67 m_NSWMM_PRD_id.push_back(Id);
68 Amg::Vector3D pos = prd.globalPosition();
69 const Amg::MatrixX & cov = prd.localCovariance();
70 Amg::Vector2D loc_pos{Amg::Vector2D::Zero()};
71 det->surface(Id).globalToLocal(pos, Amg::Vector3D::Zero(), loc_pos);
72
73 ATH_MSG_DEBUG("MicroMegas PRD local pos.: "<<Amg::toString(loc_pos)
74 << ", ex=" << std::setw(6) << std::setprecision(2) << cov(0,0));
75
76 m_NSWMM_PRD_globalPos.push_back(pos);
77 m_NSWMM_PRD_localPos.push_back(loc_pos);
78 m_NSWMM_PRD_covMatrix_1_1.push_back(cov(0,0));
79 m_NSWMM_PRD_nStrips.push_back((prd.rdoList()).size());
80
82 m_NSWMM_PRD_stripTimes.push_back(prd.stripTimes());
84
85 m_NSWMM_PRD_author.push_back(static_cast<short>(prd.author()));
86 m_NSWMM_PRD_quality.push_back(static_cast<int8_t>(prd.quality()));
87
88 unsigned idx = m_filteredPRDs.size();
89 if (m_externalPush) {
90 m_filteredPRDs.insert(std::make_pair(Id, idx));
91 }
92 return idx;
93 }
94}
#define ATH_MSG_FATAL(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
An MMReadoutElement corresponds to a single STGC module; therefore typicaly a barrel muon station con...
Identifier identify() const override final
Returns the ATLAS Identifier of the MuonReadOutElement.
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...
MatrixBranch< short unsigned > & m_NSWMM_PRD_stripNumbers
VectorBranch< uint8_t > & m_NSWMM_PRD_quality
void enableSeededDump()
Dumps only hits which are marked by the dumpAllHitsInChamber method.
unsigned int push_back(const Muon::MMPrepData &prd)
Adds a prd to the output tree.
VectorBranch< float > & m_NSWMM_PRD_covMatrix_1_1
MmIdentifierBranch m_NSWMM_PRD_id
std::unordered_set< Identifier > m_filteredChamb
Set of chambers to be dumped.
VectorBranch< int > & m_NSWMM_PRD_nStrips
void dumpAllHitsInChamber(const MuonGM::MMReadoutElement &detEle)
Adds all hits in this particular chamber to the output n-tuple.
SG::ReadHandleKey< Muon::MMPrepDataContainer > m_key
MatrixBranch< short int > & m_NSWMM_PRD_stripTimes
bool m_applyFilter
Apply a filter to dump the prds.
MMPRDVariables(MuonTesterTree &tree, const std::string &prd_container_name, MSG::Level msglvl)
Standard constructor taking the MuonTesterTree as parent The container name under which the MicroMega...
VectorBranch< short > & m_NSWMM_PRD_author
VectorBranch< int > & m_NSWMM_PRD_time
bool declare_keys() override final
unsigned int dump(const Muon::MMPrepData &prd)
ScalarBranch< unsigned int > & m_NSWMM_nPRD
TwoVectorBranch m_NSWMM_PRD_localPos
MatrixBranch< int > & m_NSWMM_PRD_stripCharges
bool m_externalPush
Flag telling whether an external prd has been pushed.
std::unordered_map< Identifier, unsigned int > m_filteredPRDs
Set of particular chambers to be dumped.
ThreeVectorBranch m_NSWMM_PRD_globalPos
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.
Class to represent MM measurements.
Definition MMPrepData.h:22
Author author() const
Definition MMPrepData.h:272
const std::vector< uint16_t > & stripNumbers() const
returns the list of strip numbers
Definition MMPrepData.h:247
Quality quality() const
Definition MMPrepData.h:168
const std::vector< short int > & stripTimes() const
returns the list of times
Definition MMPrepData.h:252
virtual const MuonGM::MMReadoutElement * detectorElement() const override final
Returns the detector element corresponding to this PRD.
Definition MMPrepData.h:206
short int time() const
Returns the time (in ns)
Definition MMPrepData.h:222
virtual const Amg::Vector3D & globalPosition() const override final
Returns the global position.
Definition MMPrepData.h:211
const std::vector< int > & stripCharges() const
returns the list of charges
Definition MMPrepData.h:257
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Identifier identify() const
return the identifier
const Amg::MatrixX & localCovariance() const
return const ref to the error matrix
const std::vector< Identifier > & rdoList() const
return the List of rdo identifiers (pointers)
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
MuonPrepDataCollection< MMPrepData > MMPrepDataCollection
-event-from-file