ATLAS Offline Software
Loading...
Searching...
No Matches
Muon::MuonEventCnvTool Class Reference

Tool used in the persisency convertors to help rebuild EDM objects. More...

#include <MuonEventCnvTool.h>

Inheritance diagram for Muon::MuonEventCnvTool:
Collaboration diagram for Muon::MuonEventCnvTool:

Public Types

enum  MuonConcreteType {
  MDT , RPC , CSC , TGC ,
  MM , STGC , TypeUnknown
}

Public Member Functions

 MuonEventCnvTool (const std::string &, const std::string &, const IInterface *)
virtual StatusCode initialize () override
virtual void checkRoT (const Trk::RIO_OnTrack &rioOnTrack) const override
 check that the RoT is correctly filled
virtual std::pair< const Trk::TrkDetElementBase *, const Trk::PrepRawData * > getLinks (Trk::RIO_OnTrack &rioOnTrack) const override
virtual void prepareRIO_OnTrack (Trk::RIO_OnTrack *rot) const override
virtual void prepareRIO_OnTrackLink (const Trk::RIO_OnTrack *rot, ELKey_t &key, ELIndex_t &index) const override
 Similar, but just return the EL components rather then changing ROT.
virtual void recreateRIO_OnTrack (Trk::RIO_OnTrack *RoT) const override
 Take the passed RoT and recreate it (i.e.
virtual const Trk::TrkDetElementBasegetDetectorElement (const Identifier &id, const IdentifierHash &idHash) const override
 Return the detectorElement associated with this Identifier.
virtual const Trk::TrkDetElementBasegetDetectorElement (const Identifier &id) const override
 Return the detectorElement associated with this Identifier.

Private Member Functions

const Trk::PrepRawDatagetLink (const Identifier &id, const IdentifierHash &idHash) const
template<class CONT>
const Trk::PrepRawDatagetLink (const Identifier &id, const IdentifierHash &idHash, const SG::ReadHandleKey< CONT > &handle, const EventContext &ctx) const

Private Attributes

ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
SG::ReadHandleKey< RpcPrepDataContainerm_rpcPrdKey {this, "RpcClusterContainer", "RPC_Measurements", "Location for RPC PRDs"}
SG::ReadHandleKey< CscPrepDataContainerm_cscPrdKey {this, "CscClusterContainer", "CSC_Clusters", "Location for CSC PRDs"}
SG::ReadHandleKey< TgcPrepDataContainerm_tgcPrdKey {this, "TgcClusterContainer", "TGC_MeasurementsAllBCs", "Location for TGC PRDs"}
SG::ReadHandleKey< MdtPrepDataContainerm_mdtPrdKey {this, "MdtClusterContainer", "MDT_DriftCircles", "Location for MDT PRDs"}
SG::ReadHandleKey< MMPrepDataContainerm_mmPrdKey {this, "MM_ClusterContainer", "MM_Measurements", "Location for MM PRDs"}
SG::ReadHandleKey< sTgcPrepDataContainerm_stgcPrdKey {this, "STGC_ClusterContainer", "STGC_Measurements", "Location for sTGC PRDs"}
SG::ReadCondHandleKey< MuonGM::MuonDetectorManagerm_detectorManagerKey
Gaudi::Property< bool > m_manuallyFindPRDs
 If true, search for PRDs manually - i.e.
Gaudi::Property< bool > m_fixTGCs {this, "FixTGCs", false, "If true, try to fix broken EL, e.g. ATLASRECTS-5151"}

Detailed Description

Tool used in the persisency convertors to help rebuild EDM objects.

Definition at line 30 of file MuonEventCnvTool.h.

Member Enumeration Documentation

◆ MuonConcreteType

Constructor & Destructor Documentation

◆ MuonEventCnvTool()

Muon::MuonEventCnvTool::MuonEventCnvTool ( const std::string & t,
const std::string & n,
const IInterface * p )

Definition at line 31 of file MuonEventCnvTool.cxx.

31: base_class(t, n, p) {}

Member Function Documentation

◆ checkRoT()

void Muon::MuonEventCnvTool::checkRoT ( const Trk::RIO_OnTrack & rioOnTrack) const
overridevirtual

check that the RoT is correctly filled

Definition at line 46 of file MuonEventCnvTool.cxx.

46 {
48 const Identifier& id = rioOnTrack.identify();
49 if (m_idHelperSvc->isRpc(id))
50 type = RPC;
51 else if (m_idHelperSvc->isTgc(id))
52 type = TGC;
53 else if (m_idHelperSvc->isMdt(id))
54 type = MDT;
55 else if (m_idHelperSvc->isMM(id))
56 type = MM;
57 else if (m_idHelperSvc->issTgc(id))
58 type = STGC;
59 else if (m_idHelperSvc->isCsc(id))
60 type = CSC;
61
62 if (type == TypeUnknown) {
63 ATH_MSG_ERROR("Type does not match known concrete type of MuonSpectrometer! Dumping RoT:" << rioOnTrack);
64 } else {
65 ATH_MSG_VERBOSE("Type = " << type << "(RPC=" << RPC << ", CSC=" << CSC << ", TGC=" << TGC << "MDT=" << MDT << ", STGC=" << STGC
66 << "MM=" << MM << ")");
67 }
68}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Identifier identify() const
return the identifier -extends MeasurementBase

◆ getDetectorElement() [1/2]

const Trk::TrkDetElementBase * Muon::MuonEventCnvTool::getDetectorElement ( const Identifier & id) const
overridevirtual

Return the detectorElement associated with this Identifier.

Definition at line 169 of file MuonEventCnvTool.cxx.

169 {
170 const EventContext& ctx = Gaudi::Hive::currentContext();
171 const MuonGM::MuonDetectorManager* muonMgr{nullptr};
172 SG::ReadCondHandle muonMgrHandle{m_detectorManagerKey, ctx};
173 if (!muonMgrHandle.isValid()) {
174 ATH_MSG_ERROR("Failed to retrieve the Muon detector manager from the conditions store");
175 return nullptr;
176 }
177 muonMgr = muonMgrHandle.cptr();
178
179 const Trk::TrkDetElementBase* detEl = nullptr;
180 // TODO Check that these are in the most likely ordering, for speed. EJWM.
181 if (m_idHelperSvc->isRpc(id)) {
182 detEl = muonMgr->getRpcReadoutElement(id);
183 } else if (m_idHelperSvc->isCsc(id)) {
184 detEl = muonMgr->getCscReadoutElement(id);
185 } else if (m_idHelperSvc->isTgc(id)) {
186 detEl = muonMgr->getTgcReadoutElement(id);
187 } else if (m_idHelperSvc->isMdt(id)) {
188 detEl = muonMgr->getMdtReadoutElement(id);
189 } else if (m_idHelperSvc->issTgc(id)) {
190 detEl = muonMgr->getsTgcReadoutElement(id);
191 } else if (m_idHelperSvc->isMM(id)) {
192 detEl = muonMgr->getMMReadoutElement(id);
193 }
194 if (!detEl) ATH_MSG_ERROR("Could not find detector element for Identifier: " << m_idHelperSvc->toString(id));
195 return detEl;
196}
const RpcReadoutElement * getRpcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
const MdtReadoutElement * getMdtReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
const MMReadoutElement * getMMReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
const TgcReadoutElement * getTgcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
const sTgcReadoutElement * getsTgcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
const CscReadoutElement * getCscReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_detectorManagerKey
const_pointer_type cptr()

◆ getDetectorElement() [2/2]

const Trk::TrkDetElementBase * Muon::MuonEventCnvTool::getDetectorElement ( const Identifier & id,
const IdentifierHash & idHash ) const
overridevirtual

Return the detectorElement associated with this Identifier.

Parameters
idHashidHash

Definition at line 165 of file MuonEventCnvTool.cxx.

165 {
166 return getDetectorElement(id);
167}
virtual const Trk::TrkDetElementBase * getDetectorElement(const Identifier &id, const IdentifierHash &idHash) const override
Return the detectorElement associated with this Identifier.

◆ getLink() [1/2]

const Trk::PrepRawData * Muon::MuonEventCnvTool::getLink ( const Identifier & id,
const IdentifierHash & idHash ) const
private

Definition at line 198 of file MuonEventCnvTool.cxx.

198 {
199 const EventContext& ctx = Gaudi::Hive::currentContext();
200 if (m_idHelperSvc->isMdt(id)) {
201 return getLink(id, idHash, m_mdtPrdKey, ctx);
202 } else if (m_idHelperSvc->isRpc(id)) {
203 return getLink(id, idHash, m_rpcPrdKey, ctx);
204 } else if (m_idHelperSvc->isTgc(id)) {
205 return getLink(id, idHash, m_tgcPrdKey, ctx);
206 } else if (m_idHelperSvc->isMM(id)) {
207 return getLink(id, idHash, m_mmPrdKey, ctx);
208 } else if (m_idHelperSvc->issTgc(id)) {
209 return getLink(id, idHash, m_stgcPrdKey, ctx);
210 }
211 ATH_MSG_ERROR("The given Identifier is not a muon one " << m_idHelperSvc->toString(id));
212 return nullptr;
213}
SG::ReadHandleKey< MdtPrepDataContainer > m_mdtPrdKey
SG::ReadHandleKey< MMPrepDataContainer > m_mmPrdKey
SG::ReadHandleKey< RpcPrepDataContainer > m_rpcPrdKey
SG::ReadHandleKey< sTgcPrepDataContainer > m_stgcPrdKey
SG::ReadHandleKey< TgcPrepDataContainer > m_tgcPrdKey
const Trk::PrepRawData * getLink(const Identifier &id, const IdentifierHash &idHash) const

◆ getLink() [2/2]

template<class CONT>
const Trk::PrepRawData * Muon::MuonEventCnvTool::getLink ( const Identifier & id,
const IdentifierHash & idHash,
const SG::ReadHandleKey< CONT > & handle,
const EventContext & ctx ) const
private

Definition at line 216 of file MuonEventCnvTool.cxx.

217 {
218 SG::ReadHandle<CONT> handle{prdKey, ctx};
219 if (!handle.isValid()) {
220 ATH_MSG_ERROR("PRD container not found at " << prdKey);
221 return nullptr;
222 } else {
223 ATH_MSG_DEBUG("PRD Cluster container found at " << prdKey);
224 }
225
226 auto ptr = handle->indexFindPtr(idHash);
227 if (!ptr) {
228 ATH_MSG_DEBUG("No matching PRD found");
229 return nullptr;
230 }
231 // if we find PRD, then recreate link
232 // loop though collection to find matching PRD.
233 // there MUST be a faster way to do this!!
234 for (const auto& collIt : *ptr) {
235 if (collIt->identify() == id) return collIt;
236 }
237 ATH_MSG_DEBUG("No matching PRD found");
238 return nullptr;
239}
#define ATH_MSG_DEBUG(x)
virtual bool isValid() override final
Can the handle be successfully dereferenced?
void * ptr(T *p)
Definition SGImplSvc.cxx:74

◆ getLinks()

std::pair< const Trk::TrkDetElementBase *, const Trk::PrepRawData * > Muon::MuonEventCnvTool::getLinks ( Trk::RIO_OnTrack & rioOnTrack) const
overridevirtual

Definition at line 70 of file MuonEventCnvTool.cxx.

70 {
71 using namespace Trk;
72 using namespace MuonGM;
73
74 const Identifier& id = rioOnTrack.identify();
75 const TrkDetElementBase* detEl = getDetectorElement(id);
76 if (!detEl) {
77 ATH_MSG_ERROR("Could not find detector element for " << m_idHelperSvc->toString(id));
78 ATH_MSG_ERROR(rioOnTrack);
79 }
80 const PrepRawData* prd = m_manuallyFindPRDs ? getLink(id, rioOnTrack.idDE()) : nullptr;
81
82 if (m_fixTGCs && m_idHelperSvc->isTgc(id) && !rioOnTrack.prepRawData()) {
83 // Okay, so we might have hit the nasty issue that the TGC EL is broken in some samples
84 // Need to fix by pointing to the key defined here (assumung it has been configured correctly for this sample)
85 Muon::TgcClusterOnTrack* tgc = dynamic_cast<Muon::TgcClusterOnTrack*>(&rioOnTrack);
87 el.resetWithKeyAndIndex(m_tgcPrdKey.key(), el.index());
88 }
89
90 ATH_MSG_VERBOSE("Found PRD at : " << prd);
91 return std::pair<const Trk::TrkDetElementBase*, const Trk::PrepRawData*>(detEl, prd);
92}
ElementLink< Muon::TgcPrepDataContainer > ElementLinkToIDC_TGC_Container
Class to implement Cluster On Track for Si.
Gaudi::Property< bool > m_manuallyFindPRDs
If true, search for PRDs manually - i.e.
Gaudi::Property< bool > m_fixTGCs
ElementLinkToIDC_TGC_Container m_rio
PrepRawData object assoicated with this measurement.
virtual const Trk::PrepRawData * prepRawData() const =0
returns the PrepRawData (also known as RIO) object to which this RIO_OnTrack is associated.
virtual IdentifierHash idDE() const =0
returns the DE hashID

◆ initialize()

StatusCode Muon::MuonEventCnvTool::initialize ( )
overridevirtual

Definition at line 33 of file MuonEventCnvTool.cxx.

33 {
34 ATH_CHECK(m_idHelperSvc.retrieve());
35 ATH_CHECK(m_rpcPrdKey.initialize());
36 ATH_CHECK(m_tgcPrdKey.initialize());
37 ATH_CHECK(m_mdtPrdKey.initialize());
38 ATH_CHECK(m_detectorManagerKey.initialize());
39 ATH_CHECK(m_cscPrdKey.initialize(!m_cscPrdKey.empty())); // check for layouts without CSCs
40 ATH_CHECK(m_mmPrdKey.initialize(!m_mmPrdKey.empty())); // check for layouts without MicroMegas
41 ATH_CHECK(m_stgcPrdKey.initialize(!m_stgcPrdKey.empty())); // check for layouts without STGCs
42
43 return StatusCode::SUCCESS;
44}
#define ATH_CHECK
Evaluate an expression and check for errors.
SG::ReadHandleKey< CscPrepDataContainer > m_cscPrdKey

◆ prepareRIO_OnTrack()

void Muon::MuonEventCnvTool::prepareRIO_OnTrack ( Trk::RIO_OnTrack * rot) const
overridevirtual

Definition at line 94 of file MuonEventCnvTool.cxx.

94 {
95 Muon::MdtDriftCircleOnTrack* mdt = dynamic_cast<Muon::MdtDriftCircleOnTrack*>(RoT);
96 if (mdt) {
97 prepareRIO_OnTrackElementLink<const Muon::MdtPrepDataContainer, Muon::MdtDriftCircleOnTrack>(mdt);
98 return;
99 }
100 Muon::CscClusterOnTrack* csc = dynamic_cast<Muon::CscClusterOnTrack*>(RoT);
101 if (csc) {
102 prepareRIO_OnTrackElementLink<const Muon::CscPrepDataContainer, Muon::CscClusterOnTrack>(csc);
103 return;
104 }
105 Muon::RpcClusterOnTrack* rpc = dynamic_cast<Muon::RpcClusterOnTrack*>(RoT);
106 if (rpc) {
107 prepareRIO_OnTrackElementLink<const Muon::RpcPrepDataContainer, Muon::RpcClusterOnTrack>(rpc);
108 return;
109 }
110 Muon::TgcClusterOnTrack* tgc = dynamic_cast<Muon::TgcClusterOnTrack*>(RoT);
111 if (tgc) {
112 prepareRIO_OnTrackElementLink<const Muon::TgcPrepDataContainer, Muon::TgcClusterOnTrack>(tgc);
113 return;
114 }
115 Muon::sTgcClusterOnTrack* stgc = dynamic_cast<Muon::sTgcClusterOnTrack*>(RoT);
116 if (stgc) {
117 prepareRIO_OnTrackElementLink<const Muon::sTgcPrepDataContainer, Muon::sTgcClusterOnTrack>(stgc);
118 return;
119 }
120 Muon::MMClusterOnTrack* mm = dynamic_cast<Muon::MMClusterOnTrack*>(RoT);
121 if (mm) {
122 prepareRIO_OnTrackElementLink<const Muon::MMPrepDataContainer, Muon::MMClusterOnTrack>(mm);
123 return;
124 }
125}

◆ prepareRIO_OnTrackLink()

void Muon::MuonEventCnvTool::prepareRIO_OnTrackLink ( const Trk::RIO_OnTrack * rot,
ELKey_t & key,
ELIndex_t & index ) const
overridevirtual

Similar, but just return the EL components rather then changing ROT.

Definition at line 127 of file MuonEventCnvTool.cxx.

127 {
128 const Muon::MdtDriftCircleOnTrack* mdt = dynamic_cast<const Muon::MdtDriftCircleOnTrack*>(RoT);
129 if (mdt) {
130 prepareRIO_OnTrackElementLink<const Muon::MdtPrepDataContainer, Muon::MdtDriftCircleOnTrack>(mdt, key, index);
131 return;
132 }
133 const Muon::CscClusterOnTrack* csc = dynamic_cast<const Muon::CscClusterOnTrack*>(RoT);
134 if (csc) {
135 prepareRIO_OnTrackElementLink<const Muon::CscPrepDataContainer, Muon::CscClusterOnTrack>(csc, key, index);
136 return;
137 }
138 const Muon::RpcClusterOnTrack* rpc = dynamic_cast<const Muon::RpcClusterOnTrack*>(RoT);
139 if (rpc) {
140 prepareRIO_OnTrackElementLink<const Muon::RpcPrepDataContainer, Muon::RpcClusterOnTrack>(rpc, key, index);
141 return;
142 }
143 const Muon::TgcClusterOnTrack* tgc = dynamic_cast<const Muon::TgcClusterOnTrack*>(RoT);
144 if (tgc) {
145 prepareRIO_OnTrackElementLink<const Muon::TgcPrepDataContainer, Muon::TgcClusterOnTrack>(tgc, key, index);
146 return;
147 }
148 const Muon::sTgcClusterOnTrack* stgc = dynamic_cast<const Muon::sTgcClusterOnTrack*>(RoT);
149 if (stgc) {
150 prepareRIO_OnTrackElementLink<const Muon::sTgcPrepDataContainer, Muon::sTgcClusterOnTrack>(stgc, key, index);
151 return;
152 }
153 const Muon::MMClusterOnTrack* mm = dynamic_cast<const Muon::MMClusterOnTrack*>(RoT);
154 if (mm) {
155 prepareRIO_OnTrackElementLink<const Muon::MMPrepDataContainer, Muon::MMClusterOnTrack>(mm, key, index);
156 return;
157 }
158 }

◆ recreateRIO_OnTrack()

void Muon::MuonEventCnvTool::recreateRIO_OnTrack ( Trk::RIO_OnTrack * RoT) const
overridevirtual

Take the passed RoT and recreate it (i.e.

fill missing pointers etc)

Definition at line 160 of file MuonEventCnvTool.cxx.

160 {
161 std::pair<const Trk::TrkDetElementBase*, const Trk::PrepRawData*> pair = getLinks(*RoT);
162 if (pair.first) Trk::ITrkEventCnvTool::setRoT_Values(pair, RoT);
163}
virtual std::pair< const Trk::TrkDetElementBase *, const Trk::PrepRawData * > getLinks(Trk::RIO_OnTrack &rioOnTrack) const override
virtual void setRoT_Values(std::pair< const Trk::TrkDetElementBase *, const Trk::PrepRawData * > &pair, Trk::RIO_OnTrack *RoT) const

Member Data Documentation

◆ m_cscPrdKey

SG::ReadHandleKey<CscPrepDataContainer> Muon::MuonEventCnvTool::m_cscPrdKey {this, "CscClusterContainer", "CSC_Clusters", "Location for CSC PRDs"}
private

Definition at line 71 of file MuonEventCnvTool.h.

71{this, "CscClusterContainer", "CSC_Clusters", "Location for CSC PRDs"};

◆ m_detectorManagerKey

SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> Muon::MuonEventCnvTool::m_detectorManagerKey
private
Initial value:
{this, "DetectorManagerKey", "MuonDetectorManager",
"Key of input MuonDetectorManager condition data"}

Definition at line 77 of file MuonEventCnvTool.h.

77 {this, "DetectorManagerKey", "MuonDetectorManager",
78 "Key of input MuonDetectorManager condition data"};

◆ m_fixTGCs

Gaudi::Property<bool> Muon::MuonEventCnvTool::m_fixTGCs {this, "FixTGCs", false, "If true, try to fix broken EL, e.g. ATLASRECTS-5151"}
private

Definition at line 84 of file MuonEventCnvTool.h.

84{this, "FixTGCs", false, "If true, try to fix broken EL, e.g. ATLASRECTS-5151"};

◆ m_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> Muon::MuonEventCnvTool::m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
private

Definition at line 68 of file MuonEventCnvTool.h.

68{this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};

◆ m_manuallyFindPRDs

Gaudi::Property<bool> Muon::MuonEventCnvTool::m_manuallyFindPRDs
private
Initial value:
{this, "FindPRDsManually", false,
"If true, search for PRDs manually - i.e. do not rely on ElementLink working"}

If true, search for PRDs manually - i.e.

do not rely on ElementLink working

Warning
This functionality is left in primarily for debugging - will probably be removed in near future.

Definition at line 82 of file MuonEventCnvTool.h.

82 {this, "FindPRDsManually", false,
83 "If true, search for PRDs manually - i.e. do not rely on ElementLink working"};

◆ m_mdtPrdKey

SG::ReadHandleKey<MdtPrepDataContainer> Muon::MuonEventCnvTool::m_mdtPrdKey {this, "MdtClusterContainer", "MDT_DriftCircles", "Location for MDT PRDs"}
private

Definition at line 73 of file MuonEventCnvTool.h.

73{this, "MdtClusterContainer", "MDT_DriftCircles", "Location for MDT PRDs"};

◆ m_mmPrdKey

SG::ReadHandleKey<MMPrepDataContainer> Muon::MuonEventCnvTool::m_mmPrdKey {this, "MM_ClusterContainer", "MM_Measurements", "Location for MM PRDs"}
private

Definition at line 74 of file MuonEventCnvTool.h.

74{this, "MM_ClusterContainer", "MM_Measurements", "Location for MM PRDs"};

◆ m_rpcPrdKey

SG::ReadHandleKey<RpcPrepDataContainer> Muon::MuonEventCnvTool::m_rpcPrdKey {this, "RpcClusterContainer", "RPC_Measurements", "Location for RPC PRDs"}
private

Definition at line 70 of file MuonEventCnvTool.h.

70{this, "RpcClusterContainer", "RPC_Measurements", "Location for RPC PRDs"};

◆ m_stgcPrdKey

SG::ReadHandleKey<sTgcPrepDataContainer> Muon::MuonEventCnvTool::m_stgcPrdKey {this, "STGC_ClusterContainer", "STGC_Measurements", "Location for sTGC PRDs"}
private

Definition at line 75 of file MuonEventCnvTool.h.

75{this, "STGC_ClusterContainer", "STGC_Measurements", "Location for sTGC PRDs"};

◆ m_tgcPrdKey

SG::ReadHandleKey<TgcPrepDataContainer> Muon::MuonEventCnvTool::m_tgcPrdKey {this, "TgcClusterContainer", "TGC_MeasurementsAllBCs", "Location for TGC PRDs"}
private

Definition at line 72 of file MuonEventCnvTool.h.

72{this, "TgcClusterContainer", "TGC_MeasurementsAllBCs", "Location for TGC PRDs"};

The documentation for this class was generated from the following files: