ATLAS Offline Software
Loading...
Searching...
No Matches
MMRDOVariables.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6
8
9using namespace Muon;
10namespace MuonPRDTest {
11 MMRDOVariables::MMRDOVariables(MuonTesterTree& tree, const std::string& container_name, MSG::Level msglvl) :
12 PrdTesterModule(tree, "RDO_MM", msglvl), m_rdokey{container_name} {}
14
15 bool MMRDOVariables::fill(const EventContext& ctx) {
16 m_externalPush = false;
17 ATH_MSG_DEBUG("do fillMMRDOVariables()");
19 if (!mmrdoContainer.isValid()) {
20 ATH_MSG_FATAL("Failed to retrieve MM rdo container " << m_rdokey.fullKey());
21 return false;
22 }
23 ATH_MSG_DEBUG("retrieved MM rdo Container with size " << mmrdoContainer->size());
24
25 if (mmrdoContainer->size() == 0) ATH_MSG_DEBUG(" MM rdo Container empty ");
26 for (const MM_RawDataCollection* coll : *mmrdoContainer) {
27 if(m_applyFilter && !m_filteredChamb.count(coll->identifierHash())){
28 continue;
29 }
30
31
32 for (const MM_RawData* rdo : *coll) {
33 dump(ctx, *rdo);
34 }
35 }
37 ATH_MSG_DEBUG(" finished fillMMRDOVariables()");
38 return true;
39 }
40
41 unsigned int MMRDOVariables::push_back(const EventContext& ctx, const Muon::MM_RawData& rdo) {
42 m_externalPush = true;
43 return dump(ctx, rdo);
44 }
45
47
49 m_applyFilter = true;
50 m_filteredChamb.insert(idHelperSvc()->moduleHash(detEle.identify()));
51 }
52
53
54 unsigned int MMRDOVariables::push_back(const EventContext& ctx, const Identifier& id) {
56 if (!mmrdoContainer.isValid()) {
57 ATH_MSG_FATAL("Failed to retrieve MM rdo container " << m_rdokey.fullKey());
58 return -1;
59 }
60 ATH_MSG_DEBUG("retrieved MM rdo Container with size " << mmrdoContainer->size());
61 const MM_RawDataCollection* coll = mmrdoContainer->indexFindPtr(idHelperSvc()->moduleHash(id));
62 for (const MM_RawData* rdo : *coll) {
63 if (rdo->identify()== id) {
64 return push_back(ctx, *rdo);
65 }
66 }
67 ATH_MSG_ERROR("The requested RDO " << idHelperSvc()->toString(id) << " was not found in the container");
68 return -1;
69 }
70
71
72 unsigned int MMRDOVariables::dump(const EventContext& ctx,const Muon::MM_RawData& rdo) {
73 const Identifier Id = rdo.identify();
74
75 if (m_filteredRDOs.count(Id)) {
76 ATH_MSG_VERBOSE("The hit has already been added " << idHelperSvc()->toString(Id));
77 return m_filteredRDOs.at(Id);
78 }
79
80 const MuonGM::MuonDetectorManager* MuonDetMgr = getDetMgr(ctx);
81 if (!MuonDetMgr) {
82 ATH_MSG_ERROR("MuonDetMgr not found");
83 return -1;
84 }
85
86 const MuonGM::MMReadoutElement* rdoEl = MuonDetMgr->getMMReadoutElement(Id);
87 if (!rdoEl) {
88 ATH_MSG_ERROR("The micromega hit "<<idHelperSvc()->toString(Id)<<" does not have a detector element attached. That should actually never happen");
89 return -1;
90 }
91 Amg::Vector2D localStripPos{Amg::Vector2D::Zero()};
92 if ( !rdoEl->stripPosition(Id,localStripPos) ) {
93 ATH_MSG_WARNING("The MM hit "<<idHelperSvc()->toString(Id)<<" does not have a valid strip position.");
94 return -1;
95
96 }
97
98 m_NSWMM_rdo_time.push_back(rdo.time());
99 m_NSWMM_rdo_relBcid.push_back(rdo.relBcid());
100 m_NSWMM_rdo_charge.push_back(rdo.charge());
101
102
103 m_NSWMM_rdo_id.push_back(Id);
104 m_NSWMM_rdo_localPosX.push_back(localStripPos.x());
105 m_NSWMM_rdo_localPosY.push_back(localStripPos.y());
106
107 Amg::Vector3D globalStripPos(0., 0., 0.);
108 rdoEl->surface(Id).localToGlobal(localStripPos,Amg::Vector3D(0.,0.,0.),globalStripPos);
109 m_NSWMM_rdo_globalPos.push_back(globalStripPos);
110
111 unsigned idx = m_filteredRDOs.size();
112 if (m_externalPush) {
113 m_filteredRDOs.insert(std::make_pair(Id, idx));
114 }
115 return idx;
116 }
117}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
An MMReadoutElement corresponds to a single STGC module; therefore typicaly a barrel muon station con...
virtual bool stripPosition(const Identifier &id, Amg::Vector2D &pos) const override final
strip position – local or global If the strip number is outside the range of valid strips,...
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 MMReadoutElement * getMMReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
Identifier identify() const override final
Returns the ATLAS Identifier of the MuonReadOutElement.
VectorBranch< int > & m_NSWMM_rdo_charge
bool declare_keys() override final
std::unordered_map< Identifier, unsigned int > m_filteredRDOs
Set of particular chambers to be dumped.
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...
MmIdentifierBranch m_NSWMM_rdo_id
bool m_externalPush
Flag telling whether an external prd has been pushed.
void dumpAllHitsInChamber(const MuonGM::MMReadoutElement &detEle)
Adds all hits in this particular chamber to the output n-tuple.
ScalarBranch< unsigned int > & m_NSWMM_nRDO
VectorBranch< double > & m_NSWMM_rdo_localPosY
unsigned int dump(const EventContext &ctx, const Muon::MM_RawData &rdo)
VectorBranch< double > & m_NSWMM_rdo_localPosX
bool m_applyFilter
Apply a filter to dump the prds.
VectorBranch< uint16_t > & m_NSWMM_rdo_relBcid
MMRDOVariables(MuonTesterTree &tree, const std::string &container_name, MSG::Level msglvl)
VectorBranch< int > & m_NSWMM_rdo_time
unsigned int push_back(const EventContext &ctx, const Muon::MM_RawData &rdo)
Adds a RDO to the output tree.
SG::ReadHandleKey< Muon::MM_RawDataContainer > m_rdokey
ThreeVectorBranch m_NSWMM_rdo_globalPos
void enableSeededDump()
Dumps only hits which are marked by the dumpAllHitsInChamber method.
std::unordered_set< IdentifierHash > m_filteredChamb
Set of chambers to be dumped.
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.
Temporary class to hold the MM RDO.
Definition MM_RawData.h:20
int time() const
Definition MM_RawData.h:62
const Identifier & identify() const
Definition MM_RawData.h:58
uint16_t relBcid() const
Definition MM_RawData.h:63
int charge() const
Definition MM_RawData.h:64
virtual bool isValid() override final
Can the handle be successfully dereferenced?
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.
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
std::string toString(CscStripStatus cstat)
Return a string description of a CSC cluster status flag.
-event-from-file