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 Member Functions

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 Function Documentation

◆ checkRoT()

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

check that the RoT is correctly filled

Definition at line 44 of file MuonEventCnvTool.cxx.

44 {
45 const Identifier& id = rioOnTrack.identify();
47 const TechIdx_t techIdx = m_idHelperSvc->technologyIndex(id);
48
49 if (techIdx == TechIdx_t::TechnologyUnknown ||
50 techIdx == TechIdx_t::TechnologyIndexMax) {
51 ATH_MSG_ERROR("Type does not match known concrete type of MuonSpectrometer! Dumping RoT:" << rioOnTrack);
52 }
53}
#define ATH_MSG_ERROR(x)
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Identifier identify() const
return the identifier -extends MeasurementBase
TechnologyIndex
enum to classify the different layers in the muon spectrometer

◆ getDetectorElement() [1/2]

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

Return the detectorElement associated with this Identifier.

Definition at line 154 of file MuonEventCnvTool.cxx.

154 {
155 const EventContext& ctx = Gaudi::Hive::currentContext();
156 const MuonGM::MuonDetectorManager* muonMgr{nullptr};
157 if (!SG::get(muonMgr, m_detectorManagerKey, ctx).isSuccess()) {
158 ATH_MSG_ERROR("Failed to retrieve the Muon detector manager from the conditions store");
159 return nullptr;
160 }
161
162 const Trk::TrkDetElementBase* detEl = muonMgr->getReadoutElement(id);
163
164 if (!detEl) {
165 ATH_MSG_ERROR("Could not find detector element for Identifier: " << m_idHelperSvc->toString(id));
166 }
167 return detEl;
168}
const MuonReadoutElement * getReadoutElement(const Identifier &id) const
Get any read out element.
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_detectorManagerKey
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.

◆ 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 150 of file MuonEventCnvTool.cxx.

150 {
151 return getDetectorElement(id);
152}
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 170 of file MuonEventCnvTool.cxx.

170 {
171 const EventContext& ctx = Gaudi::Hive::currentContext();
172 switch (m_idHelperSvc->technologyIndex(id)) {
174 case MDT:
175 return getLink(id, idHash, m_mdtPrdKey, ctx);
176 case RPC:
177 return getLink(id, idHash, m_rpcPrdKey, ctx);
178 case TGC:
179 return getLink(id, idHash, m_tgcPrdKey, ctx);
180 case MM:
181 return getLink(id, idHash, m_mmPrdKey, ctx);
182 case STGC:
183 return getLink(id, idHash, m_stgcPrdKey, ctx);
184 case CSC:
185 return getLink(id, idHash, m_cscPrdKey, ctx);
186 default:
187 break;
188 }
189 ATH_MSG_ERROR("The given Identifier is not a muon one " << m_idHelperSvc->toString(id));
190 return nullptr;
191}
@ CSC
Definition RegSelEnums.h:34
@ STGC
Definition RegSelEnums.h:39
@ MM
Definition RegSelEnums.h:38
@ RPC
Definition RegSelEnums.h:32
@ TGC
Definition RegSelEnums.h:33
@ MDT
Definition RegSelEnums.h:31
SG::ReadHandleKey< MdtPrepDataContainer > m_mdtPrdKey
SG::ReadHandleKey< MMPrepDataContainer > m_mmPrdKey
SG::ReadHandleKey< RpcPrepDataContainer > m_rpcPrdKey
SG::ReadHandleKey< CscPrepDataContainer > m_cscPrdKey
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 194 of file MuonEventCnvTool.cxx.

195 {
196 SG::ReadHandle<CONT> handle{prdKey, ctx};
197 if (!handle.isValid()) {
198 ATH_MSG_ERROR("PRD container not found at " << prdKey);
199 return nullptr;
200 } else {
201 ATH_MSG_DEBUG("PRD Cluster container found at " << prdKey);
202 }
203
204 auto ptr = handle->indexFindPtr(idHash);
205 if (!ptr) {
206 ATH_MSG_DEBUG("No matching PRD found");
207 return nullptr;
208 }
209 // if we find PRD, then recreate link
210 // loop though collection to find matching PRD.
211 // there MUST be a faster way to do this!!
212 for (const auto& collIt : *ptr) {
213 if (collIt->identify() == id) return collIt;
214 }
215 ATH_MSG_DEBUG("No matching PRD found");
216 return nullptr;
217}
#define ATH_MSG_DEBUG(x)
virtual void handle(const Incident &inc)
Handle end of run incidents to save the metadata at that point.
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 55 of file MuonEventCnvTool.cxx.

55 {
56 using namespace Trk;
57 using namespace MuonGM;
58
59 const Identifier& id = rioOnTrack.identify();
60 const TrkDetElementBase* detEl = getDetectorElement(id);
61 if (!detEl) {
62 ATH_MSG_ERROR("Could not find detector element for " << m_idHelperSvc->toString(id));
63 ATH_MSG_ERROR(rioOnTrack);
64 }
65 const PrepRawData* prd = m_manuallyFindPRDs ? getLink(id, rioOnTrack.idDE()) : nullptr;
66
67 if (m_fixTGCs && m_idHelperSvc->isTgc(id) && !rioOnTrack.prepRawData()) {
68 // Okay, so we might have hit the nasty issue that the TGC EL is broken in some samples
69 // Need to fix by pointing to the key defined here (assumung it has been configured correctly for this sample)
70 Muon::TgcClusterOnTrack* tgc = dynamic_cast<Muon::TgcClusterOnTrack*>(&rioOnTrack);
72 el.resetWithKeyAndIndex(m_tgcPrdKey.key(), el.index());
73 }
74
75 ATH_MSG_VERBOSE("Found PRD at : " << prd);
76 return std::pair<const Trk::TrkDetElementBase*, const Trk::PrepRawData*>(detEl, prd);
77}
#define ATH_MSG_VERBOSE(x)
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 31 of file MuonEventCnvTool.cxx.

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

◆ prepareRIO_OnTrack()

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

Definition at line 79 of file MuonEventCnvTool.cxx.

79 {
80 Muon::MdtDriftCircleOnTrack* mdt = dynamic_cast<Muon::MdtDriftCircleOnTrack*>(RoT);
81 if (mdt) {
82 prepareRIO_OnTrackElementLink<const Muon::MdtPrepDataContainer, Muon::MdtDriftCircleOnTrack>(mdt);
83 return;
84 }
85 Muon::CscClusterOnTrack* csc = dynamic_cast<Muon::CscClusterOnTrack*>(RoT);
86 if (csc) {
87 prepareRIO_OnTrackElementLink<const Muon::CscPrepDataContainer, Muon::CscClusterOnTrack>(csc);
88 return;
89 }
90 Muon::RpcClusterOnTrack* rpc = dynamic_cast<Muon::RpcClusterOnTrack*>(RoT);
91 if (rpc) {
92 prepareRIO_OnTrackElementLink<const Muon::RpcPrepDataContainer, Muon::RpcClusterOnTrack>(rpc);
93 return;
94 }
95 Muon::TgcClusterOnTrack* tgc = dynamic_cast<Muon::TgcClusterOnTrack*>(RoT);
96 if (tgc) {
97 prepareRIO_OnTrackElementLink<const Muon::TgcPrepDataContainer, Muon::TgcClusterOnTrack>(tgc);
98 return;
99 }
100 Muon::sTgcClusterOnTrack* stgc = dynamic_cast<Muon::sTgcClusterOnTrack*>(RoT);
101 if (stgc) {
102 prepareRIO_OnTrackElementLink<const Muon::sTgcPrepDataContainer, Muon::sTgcClusterOnTrack>(stgc);
103 return;
104 }
105 Muon::MMClusterOnTrack* mm = dynamic_cast<Muon::MMClusterOnTrack*>(RoT);
106 if (mm) {
107 prepareRIO_OnTrackElementLink<const Muon::MMPrepDataContainer, Muon::MMClusterOnTrack>(mm);
108 return;
109 }
110}

◆ 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 112 of file MuonEventCnvTool.cxx.

112 {
113 const Muon::MdtDriftCircleOnTrack* mdt = dynamic_cast<const Muon::MdtDriftCircleOnTrack*>(RoT);
114 if (mdt) {
115 prepareRIO_OnTrackElementLink<const Muon::MdtPrepDataContainer, Muon::MdtDriftCircleOnTrack>(mdt, key, index);
116 return;
117 }
118 const Muon::CscClusterOnTrack* csc = dynamic_cast<const Muon::CscClusterOnTrack*>(RoT);
119 if (csc) {
120 prepareRIO_OnTrackElementLink<const Muon::CscPrepDataContainer, Muon::CscClusterOnTrack>(csc, key, index);
121 return;
122 }
123 const Muon::RpcClusterOnTrack* rpc = dynamic_cast<const Muon::RpcClusterOnTrack*>(RoT);
124 if (rpc) {
125 prepareRIO_OnTrackElementLink<const Muon::RpcPrepDataContainer, Muon::RpcClusterOnTrack>(rpc, key, index);
126 return;
127 }
128 const Muon::TgcClusterOnTrack* tgc = dynamic_cast<const Muon::TgcClusterOnTrack*>(RoT);
129 if (tgc) {
130 prepareRIO_OnTrackElementLink<const Muon::TgcPrepDataContainer, Muon::TgcClusterOnTrack>(tgc, key, index);
131 return;
132 }
133 const Muon::sTgcClusterOnTrack* stgc = dynamic_cast<const Muon::sTgcClusterOnTrack*>(RoT);
134 if (stgc) {
135 prepareRIO_OnTrackElementLink<const Muon::sTgcPrepDataContainer, Muon::sTgcClusterOnTrack>(stgc, key, index);
136 return;
137 }
138 const Muon::MMClusterOnTrack* mm = dynamic_cast<const Muon::MMClusterOnTrack*>(RoT);
139 if (mm) {
140 prepareRIO_OnTrackElementLink<const Muon::MMPrepDataContainer, Muon::MMClusterOnTrack>(mm, key, index);
141 return;
142 }
143 }

◆ 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 145 of file MuonEventCnvTool.cxx.

145 {
146 std::pair<const Trk::TrkDetElementBase*, const Trk::PrepRawData*> pair = getLinks(*RoT);
147 if (pair.first) Trk::ITrkEventCnvTool::setRoT_Values(pair, RoT);
148}
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 68 of file MuonEventCnvTool.h.

68{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 74 of file MuonEventCnvTool.h.

74 {this, "DetectorManagerKey", "MuonDetectorManager",
75 "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 81 of file MuonEventCnvTool.h.

81{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 65 of file MuonEventCnvTool.h.

65{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 79 of file MuonEventCnvTool.h.

79 {this, "FindPRDsManually", false,
80 "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 70 of file MuonEventCnvTool.h.

70{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 71 of file MuonEventCnvTool.h.

71{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 67 of file MuonEventCnvTool.h.

67{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 72 of file MuonEventCnvTool.h.

72{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 69 of file MuonEventCnvTool.h.

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

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