ATLAS Offline Software
Loading...
Searching...
No Matches
MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.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 <fstream>
8#include <utility>
11#include "GeoModelKernel/throwExcept.h"
23
24namespace {
25 template <typename read_out> void clearCache(std::vector<std::unique_ptr<read_out>>& array) {
26 for (std::unique_ptr<read_out>& ele : array) {
27 if (ele) ele->clearCache();
28 }
29 }
30 template <typename read_out> void fillCache(std::vector<std::unique_ptr<read_out>>& array) {
31 for (std::unique_ptr<read_out>& ele : array) {
32 if (ele) ele->fillCache();
33 }
34 }
35 template <typename read_out>
36 void unpackSmartPtr(const std::vector<std::unique_ptr<read_out>>& array,
37 std::vector<const MuonGM::MuonReadoutElement*>& unpacked) {
38 unpacked.reserve(array.size() + unpacked.capacity());
39 for (const auto& ptr : array){
40 if (ptr) {
41 unpacked.push_back(ptr.get());
42 }
43 }
44 }
45}
46
47namespace MuonGM {
48
50 setName("Muon");
51 if (m_idHelperSvc.retrieve().isFailure()) {
52 THROW_EXCEPTION("MuonDetectorManager() - No IdHelper svc is available");
53 }
55 if (m_idHelperSvc->hasMDT()){
56 m_mdtArray.resize(m_idHelperSvc->mdtIdHelper().detectorElement_hash_max());
57 }
58 if (m_idHelperSvc->hasCSC()){
59 m_cscArray.resize(m_idHelperSvc->cscIdHelper().detectorElement_hash_max());
60 }
61 if (m_idHelperSvc->hasTGC()){
62 m_tgcArray.resize(m_idHelperSvc->tgcIdHelper().detectorElement_hash_max());
63 }
64 if (m_idHelperSvc->hasRPC()){
65 m_rpcArray.resize(m_idHelperSvc->rpcIdHelper().detectorElement_hash_max());
66 }
67 if (m_idHelperSvc->hasMM()){
68 m_mmcArray.resize(m_idHelperSvc->mmIdHelper().detectorElement_hash_max());
69 }
70 if (m_idHelperSvc->hasSTGC()){
71 m_stgArray.resize(m_idHelperSvc->stgcIdHelper().detectorElement_hash_max());
72 }
73 }
77
79
98 const MuonReadoutElement* reEle{nullptr};
100 switch (m_idHelperSvc->technologyIndex(id)){
101 case TechIndex::MDT:
102 reEle = getMdtReadoutElement(id);
103 break;
104 case TechIndex::RPC:
105 reEle = getRpcReadoutElement(id);
106 break;
107 case TechIndex::TGC:
108 reEle = getTgcReadoutElement(id);
109 break;
110 case TechIndex::CSC:
111 reEle = getCscReadoutElement(id);
112 break;
113 case TechIndex::MM:
114 reEle = getMMReadoutElement(id);
115 break;
116 case TechIndex::STGC:
117 reEle = getsTgcReadoutElement(id);
118 break;
119 default:
120 ATH_MSG_WARNING("Invalid technology ");
121 };
122 if (!reEle) ATH_MSG_WARNING("No readout element retrieved "<<m_idHelperSvc->toString(id));
123 return reEle;
124 }
125
126 unsigned int MuonDetectorManager::getNumTreeTops() const { return m_envelope.size(); }
127
128 PVConstLink MuonDetectorManager::getTreeTop(unsigned int i) const { return m_envelope[i]; }
129 PVLink MuonDetectorManager::getTreeTop(unsigned int i) { return m_envelope[i]; }
131 m_envelope.push_back(pV);
132 }
133
134 void MuonDetectorManager::addMuonStation(std::unique_ptr<MuonStation>&& mst) {
135 std::string key = muonStationKey(mst->getStationType(), mst->getEtaIndex(), mst->getPhiIndex());
136 m_MuonStationMap[key] = std::move(mst);
137 }
138
139 std::string MuonDetectorManager::muonStationKey(const std::string& stName, int statEtaIndex, int statPhiIndex) {
140 std::string key;
141 if (statEtaIndex < 0)
142 key = stName.substr(0, 3) + "_C_zi" + MuonGM::buildString(std::abs(statEtaIndex), 2) + "fi" +
143 MuonGM::buildString(statPhiIndex, 2);
144 else
145 key = stName.substr(0, 3) + "_A_zi" + MuonGM::buildString(std::abs(statEtaIndex), 2) + "fi" +
146 MuonGM::buildString(statPhiIndex, 2);
147 return key;
148 }
149
150 const MuonStation* MuonDetectorManager::getMuonStation(const std::string& stName, int stEtaIndex, int stPhiIndex) const {
151 std::string key = muonStationKey(stName, stEtaIndex, stPhiIndex);
152
153 std::map<std::string, std::unique_ptr<MuonStation>>::const_iterator it = m_MuonStationMap.find(key);
154 if (it != m_MuonStationMap.end())
155 return (*it).second.get();
156 else
157 return nullptr;
158 }
159
160 MuonStation* MuonDetectorManager::getMuonStation(const std::string& stName, int stEtaIndex, int stPhiIndex) {
161 std::string key = muonStationKey(stName, stEtaIndex, stPhiIndex);
162
163 std::map<std::string, std::unique_ptr<MuonStation>>::const_iterator it = m_MuonStationMap.find(key);
164 if (it != m_MuonStationMap.end())
165 return (*it).second.get();
166 else
167 return nullptr;
168 }
169
170 void MuonDetectorManager::addRpcReadoutElement(std::unique_ptr<RpcReadoutElement>&& x) {
171 const Identifier id = x->identify();
172 int idx = rpcIdentToArrayIdx(id);
173 if (m_rpcArray[idx]) {
174 ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" Trying to add ReadoutElement "<<m_idHelperSvc->toStringDetEl(id)<<" which has been already added.");
175 THROW_EXCEPTION("Double readout element assignment");
176 }
177 m_rpcArray[idx] = std::move(x);
178 ++m_n_rpcRE;
179 }
180
182 int idx = rpcIdentToArrayIdx(id);
183 return m_rpcArray[idx].get();
184 }
185
186 void MuonDetectorManager::addMMReadoutElement(std::unique_ptr<MMReadoutElement>&& x) {
187 const int array_idx = mmIdenToArrayIdx(x->identify());
188 if (m_mmcArray[array_idx]) {
189 ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" Trying to add ReadoutElement "<<m_idHelperSvc->toStringDetEl(x->identify())<<" which has been already added.");
190 THROW_EXCEPTION("Double readout element assignment");
191 }
192 m_mmcArray[array_idx] = std::move(x);
193 ++m_n_mmcRE;
194 }
195
196 void MuonDetectorManager::addsTgcReadoutElement(std::unique_ptr<sTgcReadoutElement>&& x) {
197 const int array_idx = stgcIdentToArrayIdx(x->identify());
198 if (m_stgArray[array_idx]) {
199 ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" Trying to add ReadoutElement "<<m_idHelperSvc->toStringDetEl(x->identify())<<" which has been already added.");
200 THROW_EXCEPTION("Double readout element assignment");
201 }
202 m_stgArray[array_idx] = std::move(x);
203 ++m_n_stgRE;
204 }
205
206 void MuonDetectorManager::addMdtReadoutElement(std::unique_ptr<MdtReadoutElement>&& x) {
207 const Identifier id = x->identify();
208 const int arrayIdx = mdtIdentToArrayIdx(id);
209 if (m_mdtArray[arrayIdx]) {
210 ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" Trying to add ReadoutElement "<<m_idHelperSvc->toStringDetEl(id)<<" which has been already added.");
211 THROW_EXCEPTION("Double readout element assignment");
212 }
213 m_mdtArray[arrayIdx] = std::move(x);
214 ++m_n_mdtRE;
215 }
216
218 const int arrayIdx = mdtIdentToArrayIdx(id);
219 return arrayIdx < 0 ? nullptr : m_mdtArray[arrayIdx].get();
220 }
221
223 const int arrayIdx = mdtIdentToArrayIdx(id);
224 return arrayIdx < 0 ? nullptr : m_mdtArray[arrayIdx].get();
225 }
226
227 void MuonDetectorManager::addCscReadoutElement(std::unique_ptr<CscReadoutElement>&& x) {
228 const Identifier id = x->identify();
229 const int array_idx = cscIdentToArrayIdx(id);
230 if (m_cscArray[array_idx]) {
231 ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" Trying to add ReadoutElement "<<m_idHelperSvc->toStringDetEl(id)<<" which has been already added.");
232 THROW_EXCEPTION("Double readout element assignment");
233 }
234 m_cscArray[array_idx] = std::move(x);
235 ++m_n_cscRE;
236 }
237
239 const int array_idx = cscIdentToArrayIdx(id);
240 return array_idx < 0 ? nullptr : m_cscArray[array_idx].get();
241 }
242
244 const int array_idx = cscIdentToArrayIdx(id);
245 return array_idx < 0 ? nullptr : m_cscArray[array_idx].get();
246 }
247
248 void MuonDetectorManager::addTgcReadoutElement(std::unique_ptr<TgcReadoutElement>&& x) {
249 const Identifier id = x->identify();
250 const int array_idx = tgcIdentToArrayIdx(id);
251 if (m_tgcArray[array_idx]) {
252 ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" Trying to add ReadoutElement "<<m_idHelperSvc->toStringDetEl(id)<<" which has been already added.");
253 THROW_EXCEPTION("Double readout element assignment");
254 }
255
256 m_tgcArray[array_idx] = std::move(x);
257 ++m_n_tgcRE;
258 }
259
261 const int array_idx = tgcIdentToArrayIdx(id);
262 return array_idx < 0 ? nullptr : m_tgcArray[array_idx].get();
263 }
265 const int array_idx = tgcIdentToArrayIdx(id);
266 return array_idx < 0 ? nullptr : m_tgcArray[array_idx].get();
267 }
269 const int array_idx = mmIdenToArrayIdx(id);
270 return array_idx < 0 ? nullptr : m_mmcArray[array_idx].get();
271 }
273 const int array_idx = stgcIdentToArrayIdx(id);
274 return array_idx < 0 ? nullptr : m_stgArray[array_idx].get();
275 }
277 const int hash = static_cast<int>(m_idHelperSvc->detElementHash(id));
278#ifndef NDEBUG
279 if (hash <0) {
280 ATH_MSG_WARNING("Failed to retrieve a proper hash for "<<m_idHelperSvc->toString(id));
281 return -1;
282 }
283#endif
284 return hash;
285 }
286
288 const int hash = static_cast<int>(m_idHelperSvc->detElementHash(id));
289#ifndef NDEBUG
290 if (hash <0) {
291 ATH_MSG_WARNING("Failed to retrieve a proper hash for "<<m_idHelperSvc->toString(id));
292 return -1;
293 }
294#endif
295 return hash;
296 }
298 const int hash = static_cast<int>(m_idHelperSvc->detElementHash(id));
299#ifndef NDEBUG
300 if (hash <0) {
301 ATH_MSG_WARNING("Failed to retrieve a proper hash for "<<m_idHelperSvc->toString(id));
302 return -1;
303 }
304#endif
305 return hash;
306 }
308 const int hash = static_cast<int>(m_idHelperSvc->detElementHash(id));
309#ifndef NDEBUG
310 if (hash <0) {
311 ATH_MSG_WARNING("Failed to retrieve a proper hash for "<<m_idHelperSvc->toString(id));
312 return -1;
313 }
314#endif
315 return hash;
316 }
318 const int hash = static_cast<int>(m_idHelperSvc->detElementHash(id));
319#ifndef NDEBUG
320 if (hash <0) {
321 ATH_MSG_WARNING("Failed to retrieve a proper hash for "<<m_idHelperSvc->toString(id));
322 return -1;
323 }
324#endif
325 return hash;
326 }
328 const int hash = static_cast<int>(m_idHelperSvc->detElementHash(id));
329#ifndef NDEBUG
330 if (hash <0) {
331 ATH_MSG_WARNING("Failed to retrieve a proper hash for "<<m_idHelperSvc->toString(id));
332 return -1;
333 }
334#endif
335 return hash;
336 }
337
339
340 ServiceHandle<IGeoDbTagSvc> geoDbTagSvc{"GeoDbTagSvc", "MuonDetectorManager"};
341 ATH_CHECK(geoDbTagSvc.retrieve());
342
343 bool dd2=geoDbTagSvc->getSqliteReader()!=nullptr;
344 if (dd2) ATH_MSG_INFO("DD2 Detected in MuonDetectorManager. Cancelling BEE 11 cm offset");
345
346
347 if (alineData.empty()) {
348 ATH_MSG_DEBUG("Got empty A-line container (expected for MC), not applying A-lines...");
349 return StatusCode::SUCCESS;
350 }
351
352 using Parameter = ALinePar::Parameter;
353 // loop over the container of the updates passed by the MuonAlignmentDbTool
354 unsigned int nLines{0}, nUpdates{0};
355 for (const ALinePar& ALine : alineData) {
356 nLines++;
357 ATH_MSG_DEBUG(ALine << " is new. ID = " << m_idHelperSvc->toString(ALine.identify()));
358 const std::string stType = ALine.AmdbStation();
359 const int jff = ALine.AmdbPhi();
360 const int jzz = ALine.AmdbEta();
361 const int job = ALine.AmdbJob();
362 //********************
363 // NSW Cases
364 //********************
365 if (stType[0] == 'M' || stType[0] == 'S') {
366 if (!nMMRE() || !nsTgcRE()) {
367 ATH_MSG_WARNING("Unable to set A-line; the manager does not contain NSW readout elements" );
368 continue;
369 }
370 if (stType[0] == 'M') {
371 // Micromegas
372 const int array_idx = mmIdenToArrayIdx(ALine.identify());
373 MMReadoutElement* RE = m_mmcArray[array_idx].get();
374
375 if (!RE) {
376 ATH_MSG_WARNING(ALine << " *** No MM readout element found\n"
377 << "PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and Geometry Layout in use");
378 return StatusCode::FAILURE;
379 }
380
381 RE->setDelta(ALine);
382
383 } else if (stType[0] == 'S') {
384 // sTGC
385 const int array_idx = stgcIdentToArrayIdx(ALine.identify());
386 sTgcReadoutElement* RE = m_stgArray[array_idx].get();
387
388 if (!RE) {
389 ATH_MSG_WARNING(ALine << " *** No sTGC readout element found\n"
390 << "PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and Geometry Layout in use");
391 return StatusCode::FAILURE;
392 }
393
394 RE->setDelta(ALine);
395 }
396 continue;
397 }
398
399
400 //********************
401 // Non-NSW Cases
402 //********************
403 MuonStation* thisStation = getMuonStation(stType, jzz, jff);
404 if (!thisStation) {
405 ATH_MSG_WARNING("ALinePar with AmdbId " << stType << " " << jzz << " " << jff << " " << job << "*** No MuonStation found\n"
406 << "PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and Geometry Layout in use" );
407 continue;
408 }
409
410 if (job != 0) {
411 // job different than 0 (standard for TGC conditions for Sept 2010 repro.)
412 if (stType[0] == 'T') {
413 ATH_MSG_DEBUG( "ALinePar with AmdbId " << stType << " " << jzz << " " << jff << " " << job
414 << " has JOB not 0 - this is expected for TGC" );
415 } else {
416 ATH_MSG_WARNING("ALinePar with AmdbId " << stType << " " << jzz << " " << jff << " " << job
417 << " has JOB not 0 - this is NOT EXPECTED yet for non TGC chambers - skipping this A-line" );
418 continue;
419 }
420 }
421 if (job == 0) {
422 ATH_MSG_DEBUG( "Setting delta transform for Station " << ALine);
423 using Parameter = ALinePar::Parameter;
424 double cancelBEEOffset{0.0};
425 if (dd2){
426 if (thisStation->getStationName()=="BEE") {
427 double transZ=ALine.getParameter(Parameter::transZ);
428 if (transZ>0.0) {
429 cancelBEEOffset=-110.0;
430 }
431 else {
432 cancelBEEOffset=+110.0;
433 }
434 }
435 }
436 thisStation->setDelta_fromAline(ALine.getParameter(Parameter::transS),
437 ALine.getParameter(Parameter::transZ)+cancelBEEOffset,
438 ALine.getParameter(Parameter::transT),
439 ALine.getParameter(Parameter::rotS),
440 ALine.getParameter(Parameter::rotZ),
441 ALine.getParameter(Parameter::rotT));
442
443 thisStation->clearCache();
444 thisStation->fillCache();
445 } else {
446 // job different than 0 (standard for TGC conditions for Sept 2010 repro.)
447 ATH_MSG_DEBUG( "Setting delta transform for component " << ALine);
448 thisStation->setDelta_fromAline_forComp(job,
449 ALine.getParameter(Parameter::transS),
450 ALine.getParameter(Parameter::transZ),
451 ALine.getParameter(Parameter::transT),
452 ALine.getParameter(Parameter::rotS),
453 ALine.getParameter(Parameter::rotZ),
454 ALine.getParameter(Parameter::rotT));
455
456 thisStation->getMuonReadoutElement(job)->refreshCache();
457
458 }
459 nUpdates++;
460 }
461 ATH_MSG_INFO( "# of A-lines read from the ALineMapContainer in StoreGate is " << nLines );
462 ATH_MSG_INFO( "# of deltaTransforms updated according to A-lines is " << nUpdates );
463 return StatusCode::SUCCESS;
464 }
465
467 ATH_MSG_DEBUG( "In updateDeformations()" );
468 if (blineData.empty()) {
469 ATH_MSG_DEBUG( "Got empty B-line container (expected for MC), not applying B-lines..." );
470 return StatusCode::SUCCESS;
471 } else
472 ATH_MSG_INFO( "temporary B-line container with size = " << blineData.size() );
473
474 // loop over the container of the updates passed by the MuonAlignmentDbTool
475 unsigned int nLines{0}, nUpdates{0};
476 for (const BLinePar& BLine : blineData) {
477 ++nLines;
478 const std::string stType = BLine.AmdbStation();
479 const int jff = BLine.AmdbPhi();
480 const int jzz = BLine.AmdbEta();
481 const int job = BLine.AmdbJob();
482 //********************
483 // NSW Cases
484 //********************
485 if (stType[0] == 'M' || stType[0] == 'S') {
486 if (!nMMRE() || !nsTgcRE()) {
487 ATH_MSG_WARNING("Unable to set B-line; the manager does not contain NSW readout elements" );
488 continue;
489 }
490 if (stType[0] == 'M') {
491 // Micromegas
492 const int array_idx = mmIdenToArrayIdx(BLine.identify());
493 MMReadoutElement* RE = m_mmcArray[array_idx].get();
494
495 if (!RE) {
496 ATH_MSG_WARNING("BlinePar with AmdbId " <<BLine<< " *** No MM readout element found\n"
497 << "PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and Geometry Layout in use");
498 return StatusCode::FAILURE;
499 }
500 RE->setBLinePar(BLine);
501 } else if (stType[0] == 'S') {
502 // sTGC
503 const int array_idx = stgcIdentToArrayIdx(BLine.identify());
504 sTgcReadoutElement* RE = m_stgArray[array_idx].get();
505 if (!RE) {
506 ATH_MSG_WARNING("BlinePar with AmdbId " << BLine << " *** No sTGC readout element found\n"
507 << "PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and Geometry Layout in use");
508 return StatusCode::FAILURE;
509 }
510 RE->setBLinePar(BLine);
511 }
512 continue;
513 }
514
515 //********************
516 // MDT Cases
517 //********************
518 if (stType.at(0) == 'T' || stType.at(0) == 'C' || (stType.substr(0, 3) == "BML" && std::abs(jzz) == 7)) {
519 ATH_MSG_DEBUG( "BLinePar with AmdbId " << BLine << " is not a MDT station - skipping" );
520 continue;
521 }
522 ATH_MSG_DEBUG( "BLinePar with AmdbId " <<BLine << " is new ID = " << m_idHelperSvc->toString(BLine.identify()) );
523 if (job == 0) {
524 MuonStation* thisStation = getMuonStation(stType, jzz, jff);
525 if (!thisStation) {
526 ATH_MSG_WARNING("BLinePar with AmdbId " << BLine <<
527 " *** No MuonStation found \n PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and "
528 "Geometry Layout in use");
529 continue;
530 }
531 ATH_MSG_DEBUG( "Setting deformation parameters for Station " << stType << " " << jzz << " " << jff << " ");
532 thisStation->setBline(&BLine);
533 nUpdates++;
534 } else {
535 ATH_MSG_WARNING("BLinePar with AmdbId " << stType << " " << jzz << " " << jff << " " << job << " has JOB not 0 ");
536 return StatusCode::FAILURE;
537 }
538 }
539 ATH_MSG_INFO( "# of B-lines read from the ALineMapContainer in StoreGate is " << nLines );
540 ATH_MSG_INFO( "# of deform-Transforms updated according to B-lines is " << nUpdates );
541 return StatusCode::SUCCESS;
542 }
543
545
546 if (ilineData.empty()) {
547 ATH_MSG_WARNING("Empty temporary CSC I-line container - nothing to do here" );
548 return StatusCode::SUCCESS;
549 } else
550 ATH_MSG_INFO( "temporary CSC I-line container with size = " << ilineData.size() );
551
552 // loop over the container of the updates passed by the MuonAlignmentDbTool
553 unsigned int nLines{0}, nUpdates{0};
554 for (const ALinePar& ILine : ilineData) {
555 nLines++;
556 const std::string stType = ILine.AmdbStation();
557 const int jff = ILine.AmdbPhi();
558 const int jzz = ILine.AmdbEta();
559 const int job = ILine.AmdbJob();
560 ATH_MSG_DEBUG( "CscInternalAlignmentPar with AmdbId " << ILine << " is new ID = " << m_idHelperSvc->toString(ILine.identify()) );
561 if (job == 3) {
562 MuonStation* thisStation = getMuonStation(stType, jzz, jff);
563 if (!thisStation) {
564 ATH_MSG_WARNING("CscInternalAlignmentPar with AmdbId " << ILine
565 << " *** No MuonStation found \n PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and "
566 "Geometry Layout in use");
567 continue;
568 }
569 ATH_MSG_DEBUG( "Setting CSC I-Lines for Station " <<ILine);
570 CscReadoutElement* CscRE = dynamic_cast<CscReadoutElement*>(thisStation->getMuonReadoutElement(job));
571 if (!CscRE)
572 ATH_MSG_ERROR( "The CSC I-lines container includes stations which are no CSCs! This is impossible." );
573 else {
574 CscRE->setCscInternalAlignmentPar(ILine);
575 }
576 thisStation->refreshCache();
577
578 nUpdates++;
579
580 } else {
581 ATH_MSG_ERROR( "job for CSC I-Lines= " << job << " is not 3 => This is not valid." );
582 }
583 }
584 ATH_MSG_INFO( "# of CSC I-lines read from the ILineMapContainer in StoreGate is " << nLines );
585 ATH_MSG_INFO( "# of deltaTransforms updated according to A-lines is " << nUpdates );
586 return StatusCode::SUCCESS;
587 }
589
590 if (asbuiltData.empty()) {
591 ATH_MSG_WARNING("Empty temporary As-Built container - nothing to do here" );
592 return StatusCode::SUCCESS;
593 } else
594 ATH_MSG_INFO( "temporary As-Built container with size = " << asbuiltData.size() );
595
596 // loop over the container of the updates passed by the MuonAlignmentDbTool
597 unsigned int nLines{0}, nUpdates{0};
598 for (const auto& AsBuiltPar : asbuiltData) {
599 nLines++;
600 const std::string stType = AsBuiltPar.AmdbStation();
601 const int jff = AsBuiltPar.AmdbPhi();
602 const int jzz = AsBuiltPar.AmdbEta();
603
604 ATH_MSG_DEBUG( "MdtAsBuiltPar with AmdbId " << AsBuiltPar
605 << " is new ID = " << m_idHelperSvc->toString(AsBuiltPar.identify()) );
606
607 MuonStation* thisStation = getMuonStation(stType, jzz, jff);
608 if (thisStation) {
609
610 ATH_MSG_DEBUG( "Setting as-built parameters for Station " << AsBuiltPar );
611 thisStation->setMdtAsBuiltParams(&AsBuiltPar);
612 nUpdates++;
613 } else {
614 ATH_MSG_WARNING("MdtAsBuiltPar with AmdbId " <<AsBuiltPar
615 << " *** No MuonStation found \n PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and "
616 "Geometry Layout in use");
617 continue;
618 }
619 }
620 ATH_MSG_INFO( "# of MDT As-Built read from the MdtAsBuiltMapContainer in StoreGate is " << nLines );
621 ATH_MSG_INFO( "# of deltaTransforms updated according to As-Built is " << nUpdates );
622 return StatusCode::SUCCESS;
623 }
624
626 m_nswAsBuilt = nswAsBuiltData;
627 }
628
630 m_mmAsBuilt2 = mmAsBuilt2;
631 }
632
634 m_stgcAsBuildData = stgcAsBuilt;
635 }
636
638#ifndef NDEBUG
639 if (id >= m_idHelperSvc->mdtIdHelper().detectorElement_hash_max()) {
640 ATH_MSG_WARNING(" try to getMdtReadoutElement with hashId " << (unsigned int)id << " outside range 0-"
641 << m_idHelperSvc->mdtIdHelper().detectorElement_hash_max() - 1 );
642 return nullptr;
643 }
644#endif
645 return m_mdtArray[id].get();
646 }
647
649#ifndef NDEBUG
650 if (id >= m_idHelperSvc->rpcIdHelper().detectorElement_hash_max()) {
651 ATH_MSG_WARNING(" try to getRpcReadoutElement with hashId " << (unsigned int)id << " outside range 0-"
652 << m_idHelperSvc->rpcIdHelper().detectorElement_hash_max() - 1 );
653 return nullptr;
654 }
655#endif
656 return m_rpcArray[id].get();
657 }
658
660#ifndef NDEBUG
661 if (id >= m_idHelperSvc->tgcIdHelper().detectorElement_hash_max()) {
662 ATH_MSG_WARNING(" try to getTgcReadoutElement with hashId " << (unsigned int)id << " outside range 0-"
663 << m_idHelperSvc->tgcIdHelper().detectorElement_hash_max() - 1 );
664 return nullptr;
665 }
666#endif
667 return m_tgcArray[id].get();
668 }
669
671#ifndef NDEBUG
672 if (id >= m_idHelperSvc->cscIdHelper().detectorElement_hash_max()) {
673 ATH_MSG_WARNING(" try to getCscReadoutElement with hashId " << (unsigned int)id << " outside range 0-"
674 << m_idHelperSvc->cscIdHelper().detectorElement_hash_max() - 1 );
675 return nullptr;
676 }
677#endif
678 return m_cscArray[id].get();
679 }
680
681 unsigned int MuonDetectorManager::rpcStationTypeIdx(const int stationName) const {
682 std::map<int, int>::const_iterator itr = m_rpcStatToIdx.find(stationName);
683 if (itr != m_rpcStatToIdx.end()) return itr->second;
685 }
686
687 int MuonDetectorManager::rpcStationName(const int stationIndex) const {
688 std::map<int, int>::const_iterator itr = m_rpcIdxToStat.find(stationIndex);
689 if (itr != m_rpcIdxToStat.end()) return itr->second;
690 return -1;
691 }
693
694 if (!m_idHelperSvc->hasRPC()) return;
695 const RpcIdHelper& rpcHelper{m_idHelperSvc->rpcIdHelper()};
696 m_rpcStatToIdx.insert(std::make_pair(rpcHelper.stationNameIndex("BML"), RpcStatType::BML));
697 m_rpcStatToIdx.insert(std::make_pair(rpcHelper.stationNameIndex("BMS"), RpcStatType::BMS));
698 m_rpcStatToIdx.insert(std::make_pair(rpcHelper.stationNameIndex("BOL"), RpcStatType::BOL));
699 m_rpcStatToIdx.insert(std::make_pair(rpcHelper.stationNameIndex("BOS"), RpcStatType::BOS));
700 m_rpcStatToIdx.insert(std::make_pair(rpcHelper.stationNameIndex("BMF"), RpcStatType::BMF));
701 m_rpcStatToIdx.insert(std::make_pair(rpcHelper.stationNameIndex("BOF"), RpcStatType::BOF));
702 m_rpcStatToIdx.insert(std::make_pair(rpcHelper.stationNameIndex("BOG"), RpcStatType::BOG));
703 m_rpcStatToIdx.insert(std::make_pair(rpcHelper.stationNameIndex("BME"), RpcStatType::BME));
704 m_rpcStatToIdx.insert(std::make_pair(rpcHelper.stationNameIndex("BIR"), RpcStatType::BIR));
705 m_rpcStatToIdx.insert(std::make_pair(rpcHelper.stationNameIndex("BIM"), RpcStatType::BIM));
706 m_rpcStatToIdx.insert(std::make_pair(rpcHelper.stationNameIndex("BIL"), RpcStatType::BIL));
707 m_rpcStatToIdx.insert(std::make_pair(rpcHelper.stationNameIndex("BIS"), RpcStatType::BIS));
708
709 m_rpcIdxToStat.insert(std::make_pair(RpcStatType::BML, rpcHelper.stationNameIndex("BML")));
710 m_rpcIdxToStat.insert(std::make_pair(RpcStatType::BMS, rpcHelper.stationNameIndex("BMS")));
711 m_rpcIdxToStat.insert(std::make_pair(RpcStatType::BOL, rpcHelper.stationNameIndex("BOL")));
712 m_rpcIdxToStat.insert(std::make_pair(RpcStatType::BOS, rpcHelper.stationNameIndex("BOS")));
713 m_rpcIdxToStat.insert(std::make_pair(RpcStatType::BMF, rpcHelper.stationNameIndex("BMF")));
714 m_rpcIdxToStat.insert(std::make_pair(RpcStatType::BOF, rpcHelper.stationNameIndex("BOF")));
715 m_rpcIdxToStat.insert(std::make_pair(RpcStatType::BOG, rpcHelper.stationNameIndex("BOG")));
716 m_rpcIdxToStat.insert(std::make_pair(RpcStatType::BME, rpcHelper.stationNameIndex("BME")));
717 m_rpcIdxToStat.insert(std::make_pair(RpcStatType::BIR, rpcHelper.stationNameIndex("BIR")));
718 m_rpcIdxToStat.insert(std::make_pair(RpcStatType::BIM, rpcHelper.stationNameIndex("BIM")));
719 m_rpcIdxToStat.insert(std::make_pair(RpcStatType::BIL, rpcHelper.stationNameIndex("BIL")));
720 m_rpcIdxToStat.insert(std::make_pair(RpcStatType::BIS, rpcHelper.stationNameIndex("BIS")));
721 }
722 void MuonDetectorManager::set_DBMuonVersion(const std::string& version) { m_DBMuonVersion = version; }
723 void MuonDetectorManager::setGeometryVersion(const std::string& version) { m_geometryVersion = version; }
727
728 std::vector<const MuonReadoutElement*> MuonDetectorManager::getAllReadoutElements() const {
729 std::vector<const MuonReadoutElement*> res{};
730 unpackSmartPtr(m_mdtArray, res);
731 unpackSmartPtr(m_rpcArray, res);
732 unpackSmartPtr(m_tgcArray, res);
733 unpackSmartPtr(m_stgArray, res);
734 unpackSmartPtr(m_mmcArray, res);
735 unpackSmartPtr(m_cscArray, res);
736 return res;
737 }
738
739} // namespace MuonGM
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_INFO(x,...)
#define ATH_MSG_FATAL(x,...)
std::set< ALinePar, std::less<> > ALineContainer
std::set< MdtAsBuiltPar, std::less<> > MdtAsBuiltContainer
std::set< BLinePar, std::less<> > BLineContainer
std::pair< std::vector< unsigned int >, bool > res
#define x
Parameter
amdb frame (s, z, t) = chamber frame (y, z, x)
Definition ALinePar.h:23
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
This is a "hash" representation of an Identifier.
void setCscInternalAlignmentPar(const ALinePar &)
An MMReadoutElement corresponds to a single STGC module; therefore typicaly a barrel muon station con...
void setDelta(const ALinePar &aline)
void setBLinePar(const BLinePar &bLine)
read B-line (chamber-deformation) parameters
StatusCode updateCSCInternalAlignmentMap(const ALineContainer &cscIntAline)
const RpcReadoutElement * getRpcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
const MuonReadoutElement * getReadoutElement(const Identifier &id) const
Get any read out element.
void addsTgcReadoutElement(std::unique_ptr< sTgcReadoutElement > &&reEle)
store the sTGCReadoutElement using as "key" the identifier
void addRpcReadoutElement(std::unique_ptr< RpcReadoutElement > &&reEle)
store the RpcReadoutElement using as "key" the identifier
const MdtReadoutElement * getMdtReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
int rpcIdentToArrayIdx(const Identifier &id) const
Helper method to convert the Identifier into the corresponding index accessing the array.
static std::string muonStationKey(const std::string &stName, int statEtaIndex, int statPhiIndex)
const MuonStation * getMuonStation(const std::string &stName, int eta, int phi) const
std::map< std::string, std::unique_ptr< MuonStation > > m_MuonStationMap
void addCscReadoutElement(std::unique_ptr< CscReadoutElement > &&reEle)
store the CscReadoutElement using as "key" the identifier
void addMdtReadoutElement(std::unique_ptr< MdtReadoutElement > &&reEle)
store the MdtReadoutElement using as "key" the identifier
std::vector< const MuonReadoutElement * > getAllReadoutElements() const
void addTgcReadoutElement(std::unique_ptr< TgcReadoutElement > &&reEle)
store the TgcReadoutElement using as "key" the identifier
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)
void addMMReadoutElement(std::unique_ptr< MMReadoutElement > &&reEle)
store the MMReadoutElement using as "key" the identifier
const CscReadoutElement * getCscReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
Base class for the XxxReadoutElement, with Xxx = Mdt, Rpc, Tgc, Csc.
const std::string & getStationName() const
like BMS5, T1F1, CSL1
void setMdtAsBuiltParams(const MdtAsBuiltPar *xtomo)
void setDelta_fromAline(double, double, double, double, double, double)
set the delta transform in the amdb frame and update the geoModel Delta
void setBline(const BLinePar *bline)
const MuonReadoutElement * getMuonReadoutElement(int jobIndex) const
void setDelta_fromAline_forComp(int, double, double, double, double, double, double)
An RpcReadoutElement corresponds to a single RPC module; therefore typicaly a barrel muon station con...
A TgcReadoutElement corresponds to a single TGC chamber; therefore typically a TGC station contains s...
An sTgcReadoutElement corresponds to a single STGC module; therefore typicaly a barrel muon station c...
void setBLinePar(const BLinePar &bLine)
read B-line (chamber-deformation) parameters
int stationNameIndex(const std::string &name) const
Class holding the sTGC as built conditions data and applying it.
Ensure that the Athena extensions are properly loaded.
Definition GeoMuonHits.h:27
std::string buildString(int i, int ncha)
TechnologyIndex
enum to classify the different layers in the muon spectrometer
void clearCache()
Clear the cached aux data pointers.
void * ptr(T *p)
Definition SGImplSvc.cxx:74
#define THROW_EXCEPTION(MESSAGE)
Definition throwExcept.h:10