Temporary auxiliary struct to cache the readout element's dimension in z, r & phi
111 {
112 SG::WriteCondHandle writeHandle{
m_tableKey, ctx};
115 return StatusCode::SUCCESS;
116 }
120
121 auto writeCdo = std::make_unique<RegSelSiLUT>();
122 const ActsTrk::DetectorAlignStore* alignDeltas{nullptr};
124
125 ActsTrk::GeometryContext gctx{};
128 } else {
129 gctx.
setStore(std::make_unique<ActsTrk::DetectorAlignStore>(*alignDeltas));
130 }
132
135 struct TempSelTable {
136 std::optional<double> centralPhi{};
137 double zMin{std::numeric_limits<double>::max()};
138 double zMax{-std::numeric_limits<double>::max()};
139 double rMin{std::numeric_limits<double>::max()};
140 double rMax{-std::numeric_limits<double>::max()};
141 double dPhiMin{std::numeric_limits<double>::max()};
142 double dPhiMax{-std::numeric_limits<double>::max()};
143
146 rMin = std::min(rMin,
v.perp()); rMax = std::max(rMax,
v.perp());
147 zMin = std::min(zMin,
v.z()); zMax = std::max(zMax,
v.z());
148 dPhiMin = std::min(dPhiMin, dPhi); dPhiMax = std::max(dPhiMax, dPhi);
149 }
150
151 };
153 IdentifierHash modHash{};
155 std::vector<std::unique_ptr<Acts::Volume>> objVolumes{};
156 std::vector<std::shared_ptr<const Acts::Surface>> objSurfaces{};
157 for (
const MuonGMR4::MuonReadoutElement* reEle:
m_detMgr->getAllReadoutElements(alignDeltas->
detType)) {
158
159 const Acts::Surface& surface{reEle->surface()};
160
161 const double halfTck = 0.5*reEle->thickness();
162
163 std::vector<Amg::Vector3D> localVertices{};
164 localVertices.reserve(8);
166 std::ranges::for_each(static_cast<const Acts::PlanarBounds&>(surface.bounds()).vertices(),
168 ATH_MSG_VERBOSE(__LINE__<<" - Local vertex: "<<Amg::toString(v)<<", half thickness: "<<halfTck);
169 localVertices.emplace_back(v.x(), v.y(), halfTck);
170 localVertices.emplace_back(v.x(), v.y(), -halfTck);
171 });
172
174 std::unique_ptr<Acts::VolumeBounds> volBounds{};
175 objSurfaces.emplace_back(surface.getSharedPtr());
176 switch (surface.bounds().type()) {
177 using enum Acts::SurfaceBounds::BoundsType;
178 case eRectangle:{
179 using vEnum = Acts::RectangleBounds::BoundValues;
180 const auto& bounds{static_cast<const Acts::RectangleBounds&>(surface.bounds())};
181 volBounds = std::make_unique<Acts::CuboidVolumeBounds>(bounds.get(vEnum::eMaxX),
182 bounds.get(vEnum::eMaxY),
183 halfTck);
184 break;
185 } case eTrapezoid: {
186 using vEnum = Acts::TrapezoidBounds::BoundValues;
187 const auto& bounds{static_cast<const Acts::TrapezoidBounds&>(surface.bounds())};
188 volBounds = std::make_unique<Acts::TrapezoidVolumeBounds>(bounds.get(vEnum::eHalfLengthXnegY),
189 bounds.get(vEnum::eHalfLengthXposY),
190 bounds.get(vEnum::eHalfLengthY),
191 halfTck);
192 break;
193 } default:
195 }
196 objVolumes.emplace_back(std::make_unique<Acts::Volume>(surface.localToGlobalTransform(gctx.
context()),
197 std::move(volBounds)));
198 }
199
200 ATH_MSG_VERBOSE(__LINE__<<
" - Fetched "<<localVertices.size()<<
" vertices.");
203 auto&
lut = luts.at(modHash);
204 if (!
lut.centralPhi) {
205 lut.centralPhi = loc2Glob.translation().phi();
206 }
210 <<std::format("{:.2f}/{:.2f}/{:.2f}", globVtx.perp(), globVtx.z(), globVtx.phi()));
212 }
213 }
217 module_itr != idHelper.
module_end(); ++module_itr) {
219 const auto&
lut = luts.at(modHash);
220
221 if(!
lut.centralPhi) {
222 continue;
223 }
224
225 ExpandedIdentifier exp_id{};
227 ATH_MSG_DEBUG(__LINE__<<
" - Failed retrieving ExpandedIdentifier for PRD Identifier = "
228 <<
m_idHelperSvc->toString(*module_itr) <<
". Skipping to the next PRD.");
229 continue;
230 }
231 const int detid = ( exp_id[2]<0 ? -1 : 1 );
232 const int layerid = exp_id[1]+1;
233
234 const double phiMin =
lut.centralPhi.value_or(0) +
lut.dPhiMin;
235 const double phiMax =
lut.centralPhi.value_or(0) +
lut.dPhiMax;
236
237
238 for (
const std::uint32_t robID :
getRobIDs(ctx, *module_itr)) {
240 phiMin, phiMax, layerid, detid, robID, modHash};
242 <<", "<<m);
243 writeCdo->addModule(m);
244 }
245 }
246
248 if (const auto *lut = dynamic_cast<const RegSelSiLUT*>(writeCdo.get())) {
249 lut->write(std::format(
"{:}.map",
name()));
250 }
251 }
252 if (!objVolumes.empty()) {
253 Acts::ObjVisualization3D visualHelper{};
254 for (const auto& volume : objVolumes) {
255 Acts::GeometryView3D::drawVolume(visualHelper, *volume,
257 }
258 for (const auto& surface : objSurfaces) {
259 Acts::GeometryView3D::drawSurface(visualHelper, *surface,
261 }
262 visualHelper.write(std::format(
"RegSelVolumes_{:}.obj", alignDeltas->
detType));
263
264 }
265
266 ATH_CHECK(writeHandle.
record(std::make_unique<IRegSelLUTCondData>(std::move(writeCdo))));
267 return StatusCode::SUCCESS;
268 }
#define ATH_MSG_VERBOSE(x)
DetectorType detType
The aligned detector element type.
Acts::GeometryContext context() const
void setStore(AlignmentStorePtr store)
Adds the store to the Geometry context.
static EventIDRange infiniteRunLB()
Produces an EventIDRange that is infinite in RunLumi and invalid in Time.
const_id_iterator module_end() const
int get_expanded_id(const Identifier &id, ExpandedIdentifier &exp_id, const IdContext *context) const
Create expanded id from compact id (return == 0 for OK).
const_id_iterator module_begin() const
Iterators over full set of ids.
virtual int get_module_hash(const Identifier &id, IdentifierHash &hash_id) const
size_type module_hash_max() const
the maximum hash value
IdContext module_context() const
id for module
Gaudi::Property< bool > m_printTable
SG::ReadCondHandleKey< Muon::TgcCablingMap > m_cablingTgcKey
Dependency on the Tgc cabling map.
const MuonGMR4::MuonDetectorManager * m_detMgr
Detector manager.
SG::ReadCondHandleKey< Muon::RpcCablingMap > m_cablingRpcKey
Dependency on the phase II Rpc cabling map.
Gaudi::Property< bool > m_splitTrfCache
Instantiate a new transform cache to ensure lazy transform population in the event processing.
const MuonIdHelper & getIdHelper(const ActsTrk::DetectorType type) const
Retrieve the idHelper for the given detector technology.
Gaudi::Property< bool > m_dumpObjVolumes
Dump the volumes from which the region selector tables are built.
SG::ReadCondHandleKey< ActsTrk::DetectorAlignStore > m_alignKey
Dependency on the alignment constants.
SG::WriteCondHandleKey< IRegSelLUTCondData > m_tableKey
Region selector table written by the algorithm.
std::set< std::uint32_t > getRobIDs(const EventContext &ctx, const Identifier &moduleID) const
Returns the list of ROB ids associated with the module.
SG::ReadCondHandleKey< MuonMDT_CablingMap > m_cablingMdtKey
Dependency on the Mdt cabling map.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
constexpr auto lut(Generator &&f)
std::unique_ptr< ActsTrk::DetectorAlignStore > copyDeltas(const ActsTrk::DetectorAlignStore &inStore)
Copy the alignment deltas from the inStore to a new alignment store.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
bool dPhi(const xAOD::TauJet &tau, const xAOD::CaloVertexedTopoCluster &cluster, float &out)
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
#define THROW_EXCEPTION(MESSAGE)