ATLAS Offline Software
Loading...
Searching...
No Matches
sTGCRDOVariables.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
9using namespace Muon;
10namespace MuonPRDTest {
11 sTGCRDOVariables::sTGCRDOVariables(MuonTesterTree& tree, const std::string& container_name, MSG::Level msglvl) :
12 PrdTesterModule(tree, "RDO_sTGC", msglvl), m_key{container_name} {}
14
15 bool sTGCRDOVariables::fill(const EventContext& ctx) {
16 ATH_MSG_DEBUG("do fillsTGCRDOVariables()");
17 SG::ReadHandle<STGC_RawDataContainer> stgcrdoContainer{m_key, ctx};
18 if (!stgcrdoContainer.isValid()) {
19 ATH_MSG_FATAL("Failed to retrieve stgc rdo container " << m_key.fullKey());
20 return false;
21 }
22 ATH_MSG_DEBUG("retrieved sTGC rdo Container with size " << stgcrdoContainer->size());
23
24 if (stgcrdoContainer->size() == 0) ATH_MSG_DEBUG(" sTGC rdo Container empty ");
25 for (const STGC_RawDataCollection* coll : *stgcrdoContainer) {
26 if(m_applyFilter && !m_filteredChamb.count(coll->identifyHash())){
27 continue;
28 }
29 for (const STGC_RawData* rdo : *coll) {
30 dump(ctx, *rdo);
31 }
32 }
34 ATH_MSG_DEBUG(" finished fillsTGCRDOVariables()");
35 return true;
36 }
37
38
39
40 unsigned int sTGCRDOVariables::push_back(const EventContext& ctx, const Muon::STGC_RawData& rdo) {
41 m_externalPush = true;
42 return dump(ctx, rdo);
43 }
44
46
48 m_applyFilter = true;
49 m_filteredChamb.insert(idHelperSvc()->moduleHash(detEle.identify()));
50 }
51
52
53 unsigned int sTGCRDOVariables::push_back(const EventContext& ctx, const Identifier& id) {
54 SG::ReadHandle<STGC_RawDataContainer> stgcrdoContainer{m_key, ctx};
55 if (!stgcrdoContainer.isValid()) {
56 ATH_MSG_FATAL("Failed to retrieve sTGC rdo container " << m_key.fullKey());
57 return -1;
58 }
59 ATH_MSG_DEBUG("retrieved sTGC rdo Container with size " << stgcrdoContainer->size());
60
61 const STGC_RawDataCollection* coll = stgcrdoContainer->indexFindPtr(idHelperSvc()->moduleHash(id));
62 for (const STGC_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 unsigned int sTGCRDOVariables::dump(const EventContext& ctx,const Muon::STGC_RawData& rdo) {
72 const Identifier Id = rdo.identify();
73
74 if (m_filteredRDOs.count(Id)) {
75 ATH_MSG_VERBOSE("The hit has already been added " << idHelperSvc()->toString(Id));
76 return m_filteredRDOs.at(Id);
77 }
78
79 const MuonGM::MuonDetectorManager* MuonDetMgr = getDetMgr(ctx);
80 if (!MuonDetMgr) {
81 ATH_MSG_ERROR("MuonDetMgr not found");
82 return -1;
83 }
84
85 const MuonGM::sTgcReadoutElement* rdoEl = MuonDetMgr->getsTgcReadoutElement(Id);
86 if (!rdoEl) {
87 ATH_MSG_ERROR("The sTGC hit "<<idHelperSvc()->toString(Id)<<" does not have a detector element attached. That should actually never happen");
88 return -1;
89 }
90 Amg::Vector2D localStripPos(0.,0.);
91 if (!rdoEl->stripPosition(Id,localStripPos) ) {
92 ATH_MSG_WARNING("The sTGC hit "<<idHelperSvc()->toString(Id)<<" does not have a valid strip position.");
93 return -1;
94 }
95
96 m_NSWsTGC_rdo_time.push_back(rdo.time());
97 m_NSWsTGC_rdo_tdo.push_back(rdo.tdo());
98 m_NSWsTGC_rdo_charge.push_back(rdo.charge());
99 m_NSWsTGC_rdo_bcTag.push_back(rdo.bcTag());
100 m_NSWsTGC_rdo_isDead.push_back(rdo.isDead());
101 m_NSWsTGC_rdo_id.push_back(Id);
102
103 m_NSWsTGC_rdo_localPosX.push_back(localStripPos.x());
104 m_NSWsTGC_rdo_localPosY.push_back(localStripPos.y());
105
106 Amg::Vector3D globalStripPos(0., 0., 0.);
107 rdoEl->surface(Id).localToGlobal(localStripPos,Amg::Vector3D(0.,0.,0.),globalStripPos);
108 m_NSWsTGC_rdo_globalPos.push_back(globalStripPos);
109 unsigned idx = m_filteredRDOs.size();
110 if (m_externalPush) {
111 m_filteredRDOs.insert(std::make_pair(Id, idx));
112 }
113 return idx;
114 }
115
116} // namespace MuonPRDTest
#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)
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 sTgcReadoutElement * getsTgcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
Identifier identify() const override final
Returns the ATLAS Identifier of the MuonReadOutElement.
An sTgcReadoutElement corresponds to a single STGC module; therefore typicaly a barrel muon station c...
virtual bool stripPosition(const Identifier &id, Amg::Vector2D &pos) const override final
strip position - should be renamed to channel position If the strip number is outside the range of va...
const MuonGM::MuonDetectorManager * getDetMgr(const EventContext &ctx) const
const Muon::IMuonIdHelperSvc * idHelperSvc() const
PrdTesterModule(MuonTesterTree &tree, const std::string &grp_name, MSG::Level msglvl)
unsigned int dump(const EventContext &ctx, const Muon::STGC_RawData &rdo)
VectorBranch< bool > & m_NSWsTGC_rdo_isDead
unsigned int push_back(const EventContext &ctx, const Muon::STGC_RawData &rdo)
Adds a RDO to the output tree.
VectorBranch< uint16_t > & m_NSWsTGC_rdo_bcTag
void enableSeededDump()
Dumps only hits which are marked by the dumpAllHitsInChamber method.
ThreeVectorBranch m_NSWsTGC_rdo_globalPos
std::unordered_set< IdentifierHash > m_filteredChamb
Set of chambers to be dumped.
SG::ReadHandleKey< Muon::STGC_RawDataContainer > m_key
bool m_applyFilter
Apply a filter to dump the prds.
VectorBranch< double > & m_NSWsTGC_rdo_time
void dumpAllHitsInChamber(const MuonGM::sTgcReadoutElement &detEle)
Adds all hits in this particular chamber to the output n-tuple.
ScalarBranch< unsigned int > & m_NSWsTGC_nRDO
bool declare_keys() override final
bool m_externalPush
Flag telling whether an external prd has been pushed.
VectorBranch< double > & m_NSWsTGC_rdo_localPosX
VectorBranch< double > & m_NSWsTGC_rdo_localPosY
VectorBranch< uint16_t > & m_NSWsTGC_rdo_charge
VectorBranch< uint16_t > & m_NSWsTGC_rdo_tdo
sTgcIdentifierBranch m_NSWsTGC_rdo_id
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...
sTGCRDOVariables(MuonTesterTree &tree, const std::string &container_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.
unsigned int charge() const
uint16_t bcTag() const
const Identifier identify() const
unsigned int tdo() const
float time() const
bool isDead() const
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