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();
34 template <
typename read_out>
35 void unpackSmartPtr(
const std::vector<std::unique_ptr<read_out>>& array,
36 std::vector<const MuonGM::MuonReadoutElement*>& unpacked) {
37 unpacked.reserve(array.size() + unpacked.capacity());
38 for (
const auto& ptr : array){
40 unpacked.push_back(
ptr.get());
51 THROW_EXCEPTION(
"MuonDetectorManager() - No IdHelper svc is available");
115 case TechIndex::STGC:
134 std::string key =
muonStationKey(mst->getStationType(), mst->getEtaIndex(), mst->getPhiIndex());
140 if (statEtaIndex < 0)
141 key = stName.substr(0, 3) +
"_C_zi" +
MuonGM::buildString(std::abs(statEtaIndex), 2) +
"fi" +
144 key = stName.substr(0, 3) +
"_A_zi" +
MuonGM::buildString(std::abs(statEtaIndex), 2) +
"fi" +
154 return (*it).second.get();
164 return (*it).second.get();
173 ATH_MSG_FATAL(__FILE__<<
":"<<__LINE__<<
" Trying to add ReadoutElement "<<
m_idHelperSvc->toStringDetEl(
id)<<
" 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.");
198 ATH_MSG_FATAL(__FILE__<<
":"<<__LINE__<<
" Trying to add ReadoutElement "<<
m_idHelperSvc->toStringDetEl(
x->identify())<<
" which has been already added.");
209 ATH_MSG_FATAL(__FILE__<<
":"<<__LINE__<<
" Trying to add ReadoutElement "<<
m_idHelperSvc->toStringDetEl(
id)<<
" which has been already added.");
218 return arrayIdx < 0 ? nullptr :
m_mdtArray[arrayIdx].get();
223 return arrayIdx < 0 ? nullptr :
m_mdtArray[arrayIdx].get();
230 ATH_MSG_FATAL(__FILE__<<
":"<<__LINE__<<
" Trying to add ReadoutElement "<<
m_idHelperSvc->toStringDetEl(
id)<<
" which has been already added.");
239 return array_idx < 0 ? nullptr :
m_cscArray[array_idx].get();
244 return array_idx < 0 ? nullptr :
m_cscArray[array_idx].get();
251 ATH_MSG_FATAL(__FILE__<<
":"<<__LINE__<<
" Trying to add ReadoutElement "<<
m_idHelperSvc->toStringDetEl(
id)<<
" which has been already added.");
261 return array_idx < 0 ? nullptr :
m_tgcArray[array_idx].get();
265 return array_idx < 0 ? nullptr :
m_tgcArray[array_idx].get();
269 return array_idx < 0 ? nullptr :
m_mmcArray[array_idx].get();
273 return array_idx < 0 ? nullptr :
m_stgArray[array_idx].get();
276 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));
327 const int hash =
static_cast<int>(
m_idHelperSvc->detElementHash(
id));
338 if (alineData.empty()) {
339 ATH_MSG_DEBUG(
"Got empty A-line container (expected for MC), not applying A-lines...");
340 return StatusCode::SUCCESS;
345 unsigned int nLines{0}, nUpdates{0};
346 for (
const ALinePar& ALine : alineData) {
349 const std::string stType = ALine.AmdbStation();
350 const int jff = ALine.AmdbPhi();
351 const int jzz = ALine.AmdbEta();
352 const int job = ALine.AmdbJob();
356 if (stType[0] ==
'M' || stType[0] ==
'S') {
358 ATH_MSG_WARNING(
"Unable to set A-line; the manager does not contain NSW readout elements" );
361 if (stType[0] ==
'M') {
368 <<
"PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and Geometry Layout in use");
369 return StatusCode::FAILURE;
374 }
else if (stType[0] ==
'S') {
381 <<
"PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and Geometry Layout in use");
382 return StatusCode::FAILURE;
396 ATH_MSG_WARNING(
"ALinePar with AmdbId " << stType <<
" " << jzz <<
" " << jff <<
" " << job <<
"*** No MuonStation found\n"
397 <<
"PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and Geometry Layout in use" );
403 if (stType[0] ==
'T') {
404 ATH_MSG_DEBUG(
"ALinePar with AmdbId " << stType <<
" " << jzz <<
" " << jff <<
" " << job
405 <<
" has JOB not 0 - this is expected for TGC" );
407 ATH_MSG_WARNING(
"ALinePar with AmdbId " << stType <<
" " << jzz <<
" " << jff <<
" " << job
408 <<
" has JOB not 0 - this is NOT EXPECTED yet for non TGC chambers - skipping this A-line" );
413 ATH_MSG_DEBUG(
"Setting delta transform for Station " << ALine);
416 ALine.getParameter(Parameter::transZ),
417 ALine.getParameter(Parameter::transT),
418 ALine.getParameter(Parameter::rotS),
419 ALine.getParameter(Parameter::rotZ),
420 ALine.getParameter(Parameter::rotT));
426 ATH_MSG_DEBUG(
"Setting delta transform for component " << ALine);
428 ALine.getParameter(Parameter::transS),
429 ALine.getParameter(Parameter::transZ),
430 ALine.getParameter(Parameter::transT),
431 ALine.getParameter(Parameter::rotS),
432 ALine.getParameter(Parameter::rotZ),
433 ALine.getParameter(Parameter::rotT));
440 ATH_MSG_INFO(
"# of A-lines read from the ALineMapContainer in StoreGate is " << nLines );
441 ATH_MSG_INFO(
"# of deltaTransforms updated according to A-lines is " << nUpdates );
442 return StatusCode::SUCCESS;
447 if (blineData.empty()) {
448 ATH_MSG_DEBUG(
"Got empty B-line container (expected for MC), not applying B-lines..." );
449 return StatusCode::SUCCESS;
451 ATH_MSG_INFO(
"temporary B-line container with size = " << blineData.size() );
454 unsigned int nLines{0}, nUpdates{0};
455 for (
const BLinePar& BLine : blineData) {
457 const std::string stType = BLine.AmdbStation();
458 const int jff = BLine.AmdbPhi();
459 const int jzz = BLine.AmdbEta();
460 const int job = BLine.AmdbJob();
464 if (stType[0] ==
'M' || stType[0] ==
'S') {
466 ATH_MSG_WARNING(
"Unable to set B-line; the manager does not contain NSW readout elements" );
469 if (stType[0] ==
'M') {
475 ATH_MSG_WARNING(
"BlinePar with AmdbId " <<BLine<<
" *** No MM readout element found\n"
476 <<
"PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and Geometry Layout in use");
477 return StatusCode::FAILURE;
480 }
else if (stType[0] ==
'S') {
485 ATH_MSG_WARNING(
"BlinePar with AmdbId " << BLine <<
" *** No sTGC readout element found\n"
486 <<
"PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and Geometry Layout in use");
487 return StatusCode::FAILURE;
497 if (stType.at(0) ==
'T' || stType.at(0) ==
'C' || (stType.substr(0, 3) ==
"BML" && std::abs(jzz) == 7)) {
498 ATH_MSG_DEBUG(
"BLinePar with AmdbId " << BLine <<
" is not a MDT station - skipping" );
506 " *** No MuonStation found \n PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and "
507 "Geometry Layout in use");
510 ATH_MSG_DEBUG(
"Setting deformation parameters for Station " << stType <<
" " << jzz <<
" " << jff <<
" ");
514 ATH_MSG_WARNING(
"BLinePar with AmdbId " << stType <<
" " << jzz <<
" " << jff <<
" " << job <<
" has JOB not 0 ");
515 return StatusCode::FAILURE;
518 ATH_MSG_INFO(
"# of B-lines read from the ALineMapContainer in StoreGate is " << nLines );
519 ATH_MSG_INFO(
"# of deform-Transforms updated according to B-lines is " << nUpdates );
520 return StatusCode::SUCCESS;
525 if (ilineData.empty()) {
526 ATH_MSG_WARNING(
"Empty temporary CSC I-line container - nothing to do here" );
527 return StatusCode::SUCCESS;
529 ATH_MSG_INFO(
"temporary CSC I-line container with size = " << ilineData.size() );
532 unsigned int nLines{0}, nUpdates{0};
533 for (
const ALinePar& ILine : ilineData) {
535 const std::string stType = ILine.AmdbStation();
536 const int jff = ILine.AmdbPhi();
537 const int jzz = ILine.AmdbEta();
538 const int job = ILine.AmdbJob();
539 ATH_MSG_DEBUG(
"CscInternalAlignmentPar with AmdbId " << ILine <<
" is new ID = " <<
m_idHelperSvc->toString(ILine.identify()) );
544 <<
" *** No MuonStation found \n PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and "
545 "Geometry Layout in use");
551 ATH_MSG_ERROR(
"The CSC I-lines container includes stations which are no CSCs! This is impossible." );
560 ATH_MSG_ERROR(
"job for CSC I-Lines= " << job <<
" is not 3 => This is not valid." );
563 ATH_MSG_INFO(
"# of CSC I-lines read from the ILineMapContainer in StoreGate is " << nLines );
564 ATH_MSG_INFO(
"# of deltaTransforms updated according to A-lines is " << nUpdates );
565 return StatusCode::SUCCESS;
569 if (asbuiltData.empty()) {
570 ATH_MSG_WARNING(
"Empty temporary As-Built container - nothing to do here" );
571 return StatusCode::SUCCESS;
573 ATH_MSG_INFO(
"temporary As-Built container with size = " << asbuiltData.size() );
576 unsigned int nLines{0}, nUpdates{0};
577 for (
const auto& AsBuiltPar : asbuiltData) {
579 const std::string stType = AsBuiltPar.AmdbStation();
580 const int jff = AsBuiltPar.AmdbPhi();
581 const int jzz = AsBuiltPar.AmdbEta();
584 <<
" is new ID = " <<
m_idHelperSvc->toString(AsBuiltPar.identify()) );
589 ATH_MSG_DEBUG(
"Setting as-built parameters for Station " << AsBuiltPar );
594 <<
" *** No MuonStation found \n PLEASE CHECK FOR possible MISMATCHES between alignment constants from COOL and "
595 "Geometry Layout in use");
599 ATH_MSG_INFO(
"# of MDT As-Built read from the MdtAsBuiltMapContainer in StoreGate is " << nLines );
600 ATH_MSG_INFO(
"# of deltaTransforms updated according to As-Built is " << nUpdates );
601 return StatusCode::SUCCESS;
618 if (
id >=
m_idHelperSvc->mdtIdHelper().detectorElement_hash_max()) {
619 ATH_MSG_WARNING(
" try to getMdtReadoutElement with hashId " << (
unsigned int)
id <<
" outside range 0-"
620 <<
m_idHelperSvc->mdtIdHelper().detectorElement_hash_max() - 1 );
629 if (
id >=
m_idHelperSvc->rpcIdHelper().detectorElement_hash_max()) {
630 ATH_MSG_WARNING(
" try to getRpcReadoutElement with hashId " << (
unsigned int)
id <<
" outside range 0-"
631 <<
m_idHelperSvc->rpcIdHelper().detectorElement_hash_max() - 1 );
640 if (
id >=
m_idHelperSvc->tgcIdHelper().detectorElement_hash_max()) {
641 ATH_MSG_WARNING(
" try to getTgcReadoutElement with hashId " << (
unsigned int)
id <<
" outside range 0-"
642 <<
m_idHelperSvc->tgcIdHelper().detectorElement_hash_max() - 1 );
651 if (
id >=
m_idHelperSvc->cscIdHelper().detectorElement_hash_max()) {
652 ATH_MSG_WARNING(
" try to getCscReadoutElement with hashId " << (
unsigned int)
id <<
" outside range 0-"
653 <<
m_idHelperSvc->cscIdHelper().detectorElement_hash_max() - 1 );
661 std::map<int, int>::const_iterator itr =
m_rpcStatToIdx.find(stationName);
667 std::map<int, int>::const_iterator itr =
m_rpcIdxToStat.find(stationIndex);
708 std::vector<const MuonReadoutElement*>
res{};
#define ATH_MSG_WARNING(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
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)
const sTGCAsBuiltData * m_mmAsBuilt2
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 setMmAsBuilt2(const sTGCAsBuiltData *mmAsBuilt2)
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
std::vector< const MuonReadoutElement * > getAllReadoutElements() const
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)