ATLAS Offline Software
Loading...
Searching...
No Matches
EventCnvSuperTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <typeinfo>
8
14#include "TrkSurfaces/Surface.h"
15
18 ATH_MSG_WARNING("Suppressed " << (m_errCount - m_maxErrCount)
19 << " warning or error messages");
20}
21
23 // Try to get AtlasID
24 StatusCode sc = detStore()->retrieve(m_detID, "AtlasID");
25 if (sc.isFailure()) {
26 ATH_MSG_WARNING("Could not get AtlasDetectorID ");
27 }
28
29 if (!m_doID && !m_doMuons) {
31 "This tool has been configured without either Muons or ID, and so "
32 "can't do anything. Problems likely.");
33 }
34
35 // Now try to get the tools
36 if (m_doID && !m_idCnvTool.empty()) {
37 if (m_idCnvTool.retrieve().isFailure()) {
39 "Failed to retrieve InDet helper tool "
41 << ". Will not be able to recreate ID Surfaces / Det Elements.");
42 m_doID = false;
43 } else {
44 ATH_MSG_VERBOSE("Retrieved tool " << m_idCnvTool);
45 m_haveIdCnvTool = true;
46 }
47 } else {
48 m_idCnvTool.setTypeAndName("");
49 }
50
51 if (m_doMuons && !m_muonCnvTool.empty()) {
52 if (m_muonCnvTool.retrieve().isFailure()) {
54 "Failed to retrieve Muon helper tool "
56 << ". Will not be able to recreate ID Surfaces / Det Elements.");
57 m_doMuons = false;
58 } else {
59 ATH_MSG_VERBOSE("Retrieved tool " << m_muonCnvTool);
60 m_haveMuonCnvTool = true;
61 }
62 } else {
63 m_muonCnvTool.setTypeAndName("");
64 }
65
66 // Print an extra warning if neither tool found.
69 "Failed to retrieve either and InDet or a Muon tool. Will not be able "
70 "to recreate surfaces / detector elements.");
71 m_maxErrCount = 0; // No point in further WARNINGs
72 }
73
74 return StatusCode::SUCCESS;
75}
76
78 msg() << "Finalize().";
79 if (m_errCount > 0)
80 msg() << " Tried to print " << m_errCount
81 << " error/warning messages (with maximum permissable = "
82 << m_maxErrCount << ")";
83 msg() << endmsg;
84 return StatusCode::SUCCESS;
85}
86
88 const Identifier& id) const {
89 if (m_detID == nullptr)
90 return nullptr;
91
92 if (m_detID->is_indet(id)) {
93 if (m_haveIdCnvTool) {
94 return &(*m_idCnvTool);
95 } else {
96 if ((m_errCount++) < m_maxErrCount)
97 ATH_MSG_WARNING("ID RIO_OnTrack, but have no ID cnv tool!");
98 return nullptr;
99 }
100 } else {
101 if (m_detID->is_muon(id)) {
102 if (m_haveMuonCnvTool) {
103 return &(*m_muonCnvTool);
104 } else {
105 if ((m_errCount++) < m_maxErrCount)
107 "Muon RIO_OnTrack, but have no muon cnv tool. Cannot set check "
108 "RoT.");
109 return nullptr;
110 }
111 }
112 }
113
114 if ((m_errCount++) < m_maxErrCount) {
115 std::string ident = m_detID->show_to_string(id);
116 ATH_MSG_WARNING("Unknown Identifier: (" << ident << "), that is (" << id
117 << ")");
118 }
119 return nullptr;
120}
121
123 const Identifier& id) const {
124 const Surface* surface = nullptr;
125 const Trk::ITrkEventCnvTool* cnvTool = getCnvTool(id);
126 if (cnvTool != nullptr) {
127 const TrkDetElementBase* detEl = cnvTool->getDetectorElement(id);
128 if (detEl != nullptr)
129 surface = &(detEl->surface(id));
130 else if ((m_errCount++) < m_maxErrCount)
131 ATH_MSG_WARNING("getSurface: could not get detector element from id:"
132 << id << " Returning 0.");
133 } else {
134 if ((m_errCount++) < m_maxErrCount)
136 "getSurface: could not get cnv tool for Identifier:" << id);
137 }
138 return surface;
139}
140
142 using namespace std;
143 const Trk::ITrkEventCnvTool* cnvTool = getCnvTool(RoT->identify());
144 if (cnvTool != nullptr) {
145 cnvTool->recreateRIO_OnTrack(RoT);
146 } else {
147 const type_info& info = typeid(*RoT);
148 if ((m_errCount++) < m_maxErrCount)
150 "recreateRIO_OnTrack: could not get cnv tool. Returning without "
151 "correctly filling ROT of type: "
152 << info.name());
153 }
154}
155
157 const Trk::ITrkEventCnvTool* cnvTool = getCnvTool(RoT->identify());
158 if (cnvTool != nullptr) {
159 cnvTool->prepareRIO_OnTrack(RoT);
160 } else {
161 if ((m_errCount++) < m_maxErrCount)
162 msg() << "prepareRIO_OnTrack could not find appropriate tool to prepare: "
163 << *RoT << std::endl;
164 }
165}
166
168 ELKey_t& key,
169 ELIndex_t& index) const {
170 const Trk::ITrkEventCnvTool* cnvTool = getCnvTool(RoT->identify());
171 if (cnvTool != nullptr) {
172 cnvTool->prepareRIO_OnTrackLink(RoT, key, index);
173 } else {
174 if ((m_errCount++) < m_maxErrCount)
175 msg() << "prepareRIO_OnTrack could not find appropriate tool to prepare: "
176 << *RoT << std::endl;
177 }
178}
#define endmsg
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
static Double_t sc
virtual const Trk::Surface * getSurface(const Identifier &id) const override
From passed Identifier.
ToolHandle< Trk::ITrkEventCnvTool > m_idCnvTool
Tool used to handle ID RoTs etc.
bool m_haveIdCnvTool
Flag set in intialise, letting us know whether the tool has been found.
std::atomic_int m_errCount
Current number of ERROR/WARNING messages sent to output.
const AtlasDetectorID * m_detID
virtual StatusCode initialize() override
Gaudi::Property< bool > m_doID
virtual void prepareRIO_OnTrackLink(const RIO_OnTrack *Rot, ELKey_t &key, ELIndex_t &index) const override
Take the passed RoT and return the EL components to write to disc.
Gaudi::Property< bool > m_doMuons
virtual void prepareRIO_OnTrack(RIO_OnTrack *Rot) const override
Take the passed RoT and prepare the PRD ElementLink for writing to disc.
ToolHandle< Trk::ITrkEventCnvTool > m_muonCnvTool
Tool used to handle Muon RoTs etc.
virtual StatusCode finalize() override
virtual void recreateRIO_OnTrack(RIO_OnTrack *RoT) const override
Take the passed RoT and recreate it (i.e.
Gaudi::Property< int > m_maxErrCount
virtual const Trk::ITrkEventCnvTool * getCnvTool(const Identifier &id) const override
bool m_haveMuonCnvTool
Flag set in intialise, letting us know whether the tool has been found.
virtual void prepareRIO_OnTrackLink(const Trk::RIO_OnTrack *rot, ELKey_t &key, ELIndex_t &index) const =0
Similar, but just return the EL components rather then changing ROT.
virtual const Trk::TrkDetElementBase * getDetectorElement(const Identifier &id, const IdentifierHash &idHash) const =0
Returns the detectorElement associated with this Identifier & Hash.
virtual void prepareRIO_OnTrack(Trk::RIO_OnTrack *rot) const =0
Take the passed RoT and prepare the PRD ElementLink for writing to disk.
virtual void recreateRIO_OnTrack(Trk::RIO_OnTrack *RoT) const =0
Take the passed RoT and recreate it (i.e.
Class to handle RIO On Tracks ROT) for InDet and Muons, it inherits from the common MeasurementBase.
Definition RIO_OnTrack.h:70
Identifier identify() const
return the identifier -extends MeasurementBase
Abstract Base Class for tracking surfaces.
Definition Surface.h:79
This is the base class for all tracking detector elements with read-out relevant information.
virtual const Surface & surface() const =0
Return surface associated with this detector element.
Definition index.py:1
STL namespace.
MsgStream & msg
Definition testRead.cxx:32