11#include "GeoModelKernel/throwExcept.h"
24 template <
typename read_out>
void clearCache(std::vector<std::unique_ptr<read_out>>& array) {
25 for (std::unique_ptr<read_out>& ele : array) {
26 if (ele) ele->clearCache();
29 template <
typename read_out>
void fillCache(std::vector<std::unique_ptr<read_out>>& array) {
30 for (std::unique_ptr<read_out>& ele : array) {
31 if (ele) ele->fillCache();
41 THROW_EXCEPTION(
"MuonDetectorManager() - No IdHelper svc is available");
105 case TechIndex::STGC:
124 std::string key =
muonStationKey(mst->getStationType(), mst->getEtaIndex(), mst->getPhiIndex());
130 if (statEtaIndex < 0)
131 key = stName.substr(0, 3) +
"_C_zi" +
MuonGM::buildString(std::abs(statEtaIndex), 2) +
"fi" +
134 key = stName.substr(0, 3) +
"_A_zi" +
MuonGM::buildString(std::abs(statEtaIndex), 2) +
"fi" +
144 return (*it).second.get();
154 return (*it).second.get();
163 ATH_MSG_FATAL(__FILE__<<
":"<<__LINE__<<
" Trying to add ReadoutElement "<<
m_idHelperSvc->toStringDetEl(
id)<<
" which has been already added.");
178 ATH_MSG_FATAL(__FILE__<<
":"<<__LINE__<<
" Trying to add ReadoutElement "<<
m_idHelperSvc->toStringDetEl(
x->identify())<<
" which has been already added.");
188 ATH_MSG_FATAL(__FILE__<<
":"<<__LINE__<<
" Trying to add ReadoutElement "<<
m_idHelperSvc->toStringDetEl(
x->identify())<<
" which has been already added.");
199 ATH_MSG_FATAL(__FILE__<<
":"<<__LINE__<<
" Trying to add ReadoutElement "<<
m_idHelperSvc->toStringDetEl(
id)<<
" which has been already added.");
208 return arrayIdx < 0 ? nullptr :
m_mdtArray[arrayIdx].get();
213 return arrayIdx < 0 ? nullptr :
m_mdtArray[arrayIdx].get();
220 ATH_MSG_FATAL(__FILE__<<
":"<<__LINE__<<
" Trying to add ReadoutElement "<<
m_idHelperSvc->toStringDetEl(
id)<<
" which has been already added.");
229 return array_idx < 0 ? nullptr :
m_cscArray[array_idx].get();
234 return array_idx < 0 ? nullptr :
m_cscArray[array_idx].get();
241 ATH_MSG_FATAL(__FILE__<<
":"<<__LINE__<<
" Trying to add ReadoutElement "<<
m_idHelperSvc->toStringDetEl(
id)<<
" which has been already added.");
251 return array_idx < 0 ? nullptr :
m_tgcArray[array_idx].get();
255 return array_idx < 0 ? nullptr :
m_tgcArray[array_idx].get();
259 return array_idx < 0 ? nullptr :
m_mmcArray[array_idx].get();
263 return array_idx < 0 ? nullptr :
m_stgArray[array_idx].get();
266 const int hash =
static_cast<int>(
m_idHelperSvc->detElementHash(
id));
277 const int hash =
static_cast<int>(
m_idHelperSvc->detElementHash(
id));
287 const int hash =
static_cast<int>(
m_idHelperSvc->detElementHash(
id));
297 const int hash =
static_cast<int>(
m_idHelperSvc->detElementHash(
id));
307 const int hash =
static_cast<int>(
m_idHelperSvc->detElementHash(
id));
317 const int hash =
static_cast<int>(
m_idHelperSvc->detElementHash(
id));
328 if (alineData.empty()) {
329 ATH_MSG_DEBUG(
"Got empty A-line container (expected for MC), not applying A-lines...");
330 return StatusCode::SUCCESS;
335 unsigned int nLines{0}, nUpdates{0};
336 for (
const ALinePar& ALine : alineData) {
339 const std::string stType = ALine.AmdbStation();
340 const int jff = ALine.AmdbPhi();
341 const int jzz = ALine.AmdbEta();
342 const int job = ALine.AmdbJob();
346 if (stType[0] ==
'M' || stType[0] ==
'S') {
348 ATH_MSG_WARNING(
"Unable to set A-line; the manager does not contain NSW readout elements" );
351 if (stType[0] ==
'M') {
358 <<
"PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and Geometry Layout in use");
359 return StatusCode::FAILURE;
364 }
else if (stType[0] ==
'S') {
371 <<
"PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and Geometry Layout in use");
372 return StatusCode::FAILURE;
386 ATH_MSG_WARNING(
"ALinePar with AmdbId " << stType <<
" " << jzz <<
" " << jff <<
" " << job <<
"*** No MuonStation found\n"
387 <<
"PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and Geometry Layout in use" );
393 if (stType[0] ==
'T') {
394 ATH_MSG_DEBUG(
"ALinePar with AmdbId " << stType <<
" " << jzz <<
" " << jff <<
" " << job
395 <<
" has JOB not 0 - this is expected for TGC" );
397 ATH_MSG_WARNING(
"ALinePar with AmdbId " << stType <<
" " << jzz <<
" " << jff <<
" " << job
398 <<
" has JOB not 0 - this is NOT EXPECTED yet for non TGC chambers - skipping this A-line" );
403 ATH_MSG_DEBUG(
"Setting delta transform for Station " << ALine);
406 ALine.getParameter(Parameter::transZ),
407 ALine.getParameter(Parameter::transT),
408 ALine.getParameter(Parameter::rotS),
409 ALine.getParameter(Parameter::rotZ),
410 ALine.getParameter(Parameter::rotT));
416 ATH_MSG_DEBUG(
"Setting delta transform for component " << ALine);
418 ALine.getParameter(Parameter::transS),
419 ALine.getParameter(Parameter::transZ),
420 ALine.getParameter(Parameter::transT),
421 ALine.getParameter(Parameter::rotS),
422 ALine.getParameter(Parameter::rotZ),
423 ALine.getParameter(Parameter::rotT));
430 ATH_MSG_INFO(
"# of A-lines read from the ALineMapContainer in StoreGate is " << nLines );
431 ATH_MSG_INFO(
"# of deltaTransforms updated according to A-lines is " << nUpdates );
432 return StatusCode::SUCCESS;
437 if (blineData.empty()) {
438 ATH_MSG_DEBUG(
"Got empty B-line container (expected for MC), not applying B-lines..." );
439 return StatusCode::SUCCESS;
441 ATH_MSG_INFO(
"temporary B-line container with size = " << blineData.size() );
444 unsigned int nLines{0}, nUpdates{0};
445 for (
const BLinePar& BLine : blineData) {
447 const std::string stType = BLine.AmdbStation();
448 const int jff = BLine.AmdbPhi();
449 const int jzz = BLine.AmdbEta();
450 const int job = BLine.AmdbJob();
454 if (stType[0] ==
'M' || stType[0] ==
'S') {
456 ATH_MSG_WARNING(
"Unable to set B-line; the manager does not contain NSW readout elements" );
459 if (stType[0] ==
'M') {
465 ATH_MSG_WARNING(
"BlinePar with AmdbId " <<BLine<<
" *** No MM readout element found\n"
466 <<
"PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and Geometry Layout in use");
467 return StatusCode::FAILURE;
470 }
else if (stType[0] ==
'S') {
475 ATH_MSG_WARNING(
"BlinePar with AmdbId " << BLine <<
" *** No sTGC readout element found\n"
476 <<
"PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and Geometry Layout in use");
477 return StatusCode::FAILURE;
487 if (stType.at(0) ==
'T' || stType.at(0) ==
'C' || (stType.substr(0, 3) ==
"BML" && std::abs(jzz) == 7)) {
488 ATH_MSG_DEBUG(
"BLinePar with AmdbId " << BLine <<
" is not a MDT station - skipping" );
496 " *** No MuonStation found \n PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and "
497 "Geometry Layout in use");
500 ATH_MSG_DEBUG(
"Setting deformation parameters for Station " << stType <<
" " << jzz <<
" " << jff <<
" ");
504 ATH_MSG_WARNING(
"BLinePar with AmdbId " << stType <<
" " << jzz <<
" " << jff <<
" " << job <<
" has JOB not 0 ");
505 return StatusCode::FAILURE;
508 ATH_MSG_INFO(
"# of B-lines read from the ALineMapContainer in StoreGate is " << nLines );
509 ATH_MSG_INFO(
"# of deform-Transforms updated according to B-lines is " << nUpdates );
510 return StatusCode::SUCCESS;
515 if (ilineData.empty()) {
516 ATH_MSG_WARNING(
"Empty temporary CSC I-line container - nothing to do here" );
517 return StatusCode::SUCCESS;
519 ATH_MSG_INFO(
"temporary CSC I-line container with size = " << ilineData.size() );
522 unsigned int nLines{0}, nUpdates{0};
523 for (
const ALinePar& ILine : ilineData) {
525 const std::string stType = ILine.AmdbStation();
526 const int jff = ILine.AmdbPhi();
527 const int jzz = ILine.AmdbEta();
528 const int job = ILine.AmdbJob();
529 ATH_MSG_DEBUG(
"CscInternalAlignmentPar with AmdbId " << ILine <<
" is new ID = " <<
m_idHelperSvc->toString(ILine.identify()) );
534 <<
" *** No MuonStation found \n PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and "
535 "Geometry Layout in use");
541 ATH_MSG_ERROR(
"The CSC I-lines container includes stations which are no CSCs! This is impossible." );
550 ATH_MSG_ERROR(
"job for CSC I-Lines= " << job <<
" is not 3 => This is not valid." );
553 ATH_MSG_INFO(
"# of CSC I-lines read from the ILineMapContainer in StoreGate is " << nLines );
554 ATH_MSG_INFO(
"# of deltaTransforms updated according to A-lines is " << nUpdates );
555 return StatusCode::SUCCESS;
559 if (asbuiltData.empty()) {
560 ATH_MSG_WARNING(
"Empty temporary As-Built container - nothing to do here" );
561 return StatusCode::SUCCESS;
563 ATH_MSG_INFO(
"temporary As-Built container with size = " << asbuiltData.size() );
566 unsigned int nLines{0}, nUpdates{0};
567 for (
const auto& AsBuiltPar : asbuiltData) {
569 const std::string stType = AsBuiltPar.AmdbStation();
570 const int jff = AsBuiltPar.AmdbPhi();
571 const int jzz = AsBuiltPar.AmdbEta();
574 <<
" is new ID = " <<
m_idHelperSvc->toString(AsBuiltPar.identify()) );
579 ATH_MSG_DEBUG(
"Setting as-built parameters for Station " << AsBuiltPar );
584 <<
" *** No MuonStation found \n PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and "
585 "Geometry Layout in use");
589 ATH_MSG_INFO(
"# of MDT As-Built read from the MdtAsBuiltMapContainer in StoreGate is " << nLines );
590 ATH_MSG_INFO(
"# of deltaTransforms updated according to As-Built is " << nUpdates );
591 return StatusCode::SUCCESS;
604 if (
id >=
m_idHelperSvc->mdtIdHelper().detectorElement_hash_max()) {
605 ATH_MSG_WARNING(
" try to getMdtReadoutElement with hashId " << (
unsigned int)
id <<
" outside range 0-"
606 <<
m_idHelperSvc->mdtIdHelper().detectorElement_hash_max() - 1 );
615 if (
id >=
m_idHelperSvc->rpcIdHelper().detectorElement_hash_max()) {
616 ATH_MSG_WARNING(
" try to getRpcReadoutElement with hashId " << (
unsigned int)
id <<
" outside range 0-"
617 <<
m_idHelperSvc->rpcIdHelper().detectorElement_hash_max() - 1 );
626 if (
id >=
m_idHelperSvc->tgcIdHelper().detectorElement_hash_max()) {
627 ATH_MSG_WARNING(
" try to getTgcReadoutElement with hashId " << (
unsigned int)
id <<
" outside range 0-"
628 <<
m_idHelperSvc->tgcIdHelper().detectorElement_hash_max() - 1 );
637 if (
id >=
m_idHelperSvc->cscIdHelper().detectorElement_hash_max()) {
638 ATH_MSG_WARNING(
" try to getCscReadoutElement with hashId " << (
unsigned int)
id <<
" outside range 0-"
639 <<
m_idHelperSvc->cscIdHelper().detectorElement_hash_max() - 1 );
647 std::map<int, int>::const_iterator itr =
m_rpcStatToIdx.find(stationName);
653 std::map<int, int>::const_iterator itr =
m_rpcIdxToStat.find(stationIndex);
#define ATH_MSG_WARNING(x)
std::set< ALinePar, std::less<> > ALineContainer
std::set< MdtAsBuiltPar, std::less<> > MdtAsBuiltContainer
std::set< BLinePar, std::less<> > BLineContainer
Parameter
amdb frame (s, z, t) = chamber frame (y, z, x)
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
std::vector< std::unique_ptr< sTgcReadoutElement > > m_stgArray
unsigned int rpcStationTypeIdx(const int stationName) const
std::map< int, int > m_rpcIdxToStat
StatusCode updateCSCInternalAlignmentMap(const ALineContainer &cscIntAline)
std::vector< std::unique_ptr< TgcReadoutElement > > m_tgcArray
const RpcReadoutElement * getRpcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
std::string m_geometryVersion
const NswPassivationDbData * m_mmPassivation
std::vector< PVLink > m_envelope
int rpcStationName(const int stationIndex) const
const sTGCAsBuiltData * m_stgcAsBuildData
const MuonReadoutElement * getReadoutElement(const Identifier &id) const
Get any read out element.
std::vector< std::unique_ptr< CscReadoutElement > > m_cscArray
int tgcIdentToArrayIdx(const Identifier &id) const
std::vector< std::unique_ptr< MMReadoutElement > > m_mmcArray
virtual unsigned int getNumTreeTops() const
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)
StatusCode updateDeformations(const BLineContainer &a)
int mdtIdentToArrayIdx(const Identifier &id) const
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)
void setMMPassivation(const NswPassivationDbData *passiv)
void setNswAsBuilt(const NswAsBuiltDbData *nswAsBuiltData)
void setsTGCAsBuilt(const sTGCAsBuiltData *stgcAsBuilt)
virtual PVConstLink getTreeTop(unsigned int i) const
const MuonStation * getMuonStation(const std::string &stName, int eta, int phi) const
std::map< std::string, std::unique_ptr< MuonStation > > m_MuonStationMap
StatusCode updateMdtAsBuiltParams(const MdtAsBuiltContainer &a)
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
void setCutoutsFlag(int flag)
void addMuonStation(std::unique_ptr< MuonStation > &&mst)
void loadStationIndices()
int mmIdenToArrayIdx(const Identifier &id) const
StatusCode updateAlignment(const ALineContainer &a)
std::vector< std::unique_ptr< MdtReadoutElement > > m_mdtArray
std::map< int, int > m_rpcStatToIdx
RPC name caches.
int cscIdentToArrayIdx(const Identifier &id) const
void set_DBMuonVersion(const std::string &version)
void setGeometryVersion(const std::string &version)
void addTgcReadoutElement(std::unique_ptr< TgcReadoutElement > &&reEle)
store the TgcReadoutElement using as "key" the identifier
unsigned int nMMRE() const
Number of MM ReadoutElements.
const MMReadoutElement * getMMReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
std::string m_DBMuonVersion
int stgcIdentToArrayIdx(const Identifier &id) const
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 NswAsBuiltDbData * m_nswAsBuilt
std::vector< std::unique_ptr< RpcReadoutElement > > m_rpcArray
const CscReadoutElement * getCscReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
void setMinimalGeoFlag(int flag)
unsigned int nsTgcRE() const
Number of sTgc ReadoutElements.
void setCutoutsBogFlag(int flag)
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Base class for the XxxReadoutElement, with Xxx = Mdt, Rpc, Tgc, Csc.
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
void setDelta(const ALinePar &aline)
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.
std::string buildString(int i, int ncha)
TechnologyIndex
enum to classify the different layers in the muon spectrometer
#define THROW_EXCEPTION(MESSAGE)