Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GeoModelCscTest.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 #include "GeoModelCscTest.h"
5 
6 #include <fstream>
7 #include <iostream>
8 
13 
14 
15 namespace MuonGM {
16 
19  return StatusCode::SUCCESS;
20 }
23  ATH_CHECK(m_idHelperSvc.retrieve());
24  ATH_CHECK(m_tree.init(this));
25 
26  const CscIdHelper& idHelper{m_idHelperSvc->cscIdHelper()};
27  auto translateTokenList = [this, &idHelper](const std::vector<std::string>& chNames){
28 
29  std::set<Identifier> transcriptedIds{};
30  for (const std::string& token : chNames) {
31  if (token.size() != 6) {
32  ATH_MSG_WARNING("Wrong format given for "<<token<<". Expecting 6 characters");
33  continue;
34  }
36  const std::string statName = token.substr(0, 3);
37  const unsigned statEta = std::atoi(token.substr(3, 1).c_str()) * (token[4] == 'A' ? 1 : -1);
38  const unsigned statPhi = std::atoi(token.substr(5, 1).c_str());
39  bool isValid{false};
40  const Identifier eleId = idHelper.elementID(statName, statEta, statPhi, isValid);
41  if (!isValid) {
42  ATH_MSG_WARNING("Failed to deduce a station name for " << token);
43  continue;
44  }
45  transcriptedIds.insert(eleId);
46  const Identifier secMlId = idHelper.channelID(eleId,2, 1, 0, 1, isValid);
47  if (isValid){
48  transcriptedIds.insert(m_idHelperSvc->detElId(secMlId));
49  }
50  }
51  return transcriptedIds;
52  };
53 
54  std::vector <std::string>& selectedSt = m_selectStat.value();
55  const std::vector <std::string>& excludedSt = m_excludeStat.value();
56  selectedSt.erase(std::remove_if(selectedSt.begin(), selectedSt.end(),
57  [&excludedSt](const std::string& token){
58  return std::ranges::find(excludedSt, token) != excludedSt.end();
59  }), selectedSt.end());
60 
61  if (selectedSt.size()) {
62  m_testStations = translateTokenList(selectedSt);
63  std::stringstream sstr{};
64  for (const Identifier& id : m_testStations) {
65  sstr<<" *** "<<m_idHelperSvc->toString(id)<<std::endl;
66  }
67  ATH_MSG_INFO("Test only the following stations "<<std::endl<<sstr.str());
68  } else {
69  const std::set<Identifier> excluded = translateTokenList(excludedSt);
71  for(auto itr = idHelper.detectorElement_begin();
72  itr!= idHelper.detectorElement_end();++itr){
73  if (!excluded.count(*itr)) {
74  m_testStations.insert(*itr);
75  }
76  }
78  if (!excluded.empty()) {
79  std::stringstream excluded_report{};
80  for (const Identifier& id : excluded){
81  excluded_report << " *** " << m_idHelperSvc->toStringDetEl(id) << std::endl;
82  }
83  ATH_MSG_INFO("Test all station except the following excluded ones " << std::endl << excluded_report.str());
84  }
85  }
86  return StatusCode::SUCCESS;
87 }
89  const EventContext& ctx{Gaudi::Hive::currentContext()};
91  if (!detMgr.isValid()) {
92  ATH_MSG_FATAL("Failed to retrieve MuonDetectorManager "
93  << m_detMgrKey.fullKey());
94  return StatusCode::FAILURE;
95  }
96  for (const Identifier& test_me : m_testStations) {
97  ATH_MSG_VERBOSE("Test retrieval of Mdt detector element "
98  << m_idHelperSvc->toStringDetEl(test_me));
99  const CscReadoutElement* reElement = detMgr->getCscReadoutElement(test_me);
100  if (!reElement) {
101  ATH_MSG_VERBOSE("Detector element is invalid");
102  continue;
103  }
105  if (reElement->identify() != test_me) {
106  ATH_MSG_FATAL("Expected to retrieve "
107  << m_idHelperSvc->toStringDetEl(test_me) << ". But got instead "
108  << m_idHelperSvc->toStringDetEl(reElement->identify()));
109  return StatusCode::FAILURE;
110  }
111  ATH_CHECK(dumpToTree(ctx, reElement));
112  }
113  return StatusCode::SUCCESS;
114 }
115 StatusCode GeoModelCscTest::dumpToTree(const EventContext& ctx, const CscReadoutElement* readoutEle) {
116  m_stIndex = readoutEle->getStationIndex();
117  m_stEta = readoutEle->getStationEta();
118  m_stPhi = readoutEle->getStationPhi();
119  m_stMultiLayer = readoutEle->ChamberLayer();
120 
121  const CscIdHelper& idHelper{m_idHelperSvc->cscIdHelper()};
122 
123  const Amg::Transform3D& trans{readoutEle->transform()};
124  m_readoutTransform = trans;
125 
126  const MuonGM::MuonStation* station = readoutEle->parentMuonStation();
127  if (station->hasALines()){
128  m_ALineTransS = station->getALine_tras();
129  m_ALineTransT = station->getALine_traz();
130  m_ALineTransZ = station->getALine_trat();
131  m_ALineRotS = station->getALine_rots();
132  m_ALineRotT = station->getALine_rotz();
133  m_ALineRotZ = station->getALine_rott();
134  }
135  for (bool measPhi : {false, true}) {
136  for (int layer = 1 ; layer <= readoutEle->numberOfLayers(measPhi); ++layer){
137  const Identifier id = idHelper.channelID(readoutEle->identify(),readoutEle->ChamberLayer(),layer, measPhi,1);
138  m_layerTrans.push_back(readoutEle->localToGlobalTransf(id));
139  m_layMeasPhi.push_back(measPhi);
141  }
142  }
143  return m_tree.fill(ctx) ? StatusCode::SUCCESS : StatusCode::FAILURE;
144 }
145 
146 
147 }
MuonGM::GeoModelCscTest::m_ALineTransS
MuonVal::ScalarBranch< float > & m_ALineTransS
Alignment parameters.
Definition: GeoModelCscTest.h:62
MuonGM::GeoModelCscTest::m_selectStat
Gaudi::Property< std::vector< std::string > > m_selectStat
String should be formated like <stationName><stationEta><A/C><stationPhi>
Definition: GeoModelCscTest.h:46
MuonGM::MuonClusterReadoutElement::transform
virtual const Amg::Transform3D & transform() const override
Return local to global transform.
Definition: MuonClusterReadoutElement.h:124
MuonGM::MuonStation::getALine_trat
double getALine_trat() const
Definition: MuonStation.h:203
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
MuonGM
Ensure that the Athena extensions are properly loaded.
Definition: GeoMuonHits.h:27
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
MuonVal::MuonTesterTree::init
StatusCode init(OWNER *instance)
Initialize method.
MuonGM::GeoModelCscTest::m_stEta
MuonVal::ScalarBranch< short > & m_stEta
Definition: GeoModelCscTest.h:54
MuonGM::MuonStation::getALine_rotz
double getALine_rotz() const
Definition: MuonStation.h:205
MuonGM::MuonStation::getALine_traz
double getALine_traz() const
Definition: MuonStation.h:202
MuonGM::CscReadoutElement::ChamberLayer
int ChamberLayer() const
Definition: CscReadoutElement.h:290
MuonGM::GeoModelCscTest::m_readoutTransform
MuonVal::CoordTransformBranch m_readoutTransform
Transformation of the readout element (Translation, ColX, ColY, ColZ)
Definition: GeoModelCscTest.h:59
MuonGM::MuonStation::getALine_tras
double getALine_tras() const
Definition: MuonStation.h:201
MuonGM::GeoModelCscTest::m_layMeasPhi
MuonVal::VectorBranch< bool > & m_layMeasPhi
Definition: GeoModelCscTest.h:71
GeoModelCscTest.h
MuonGM::CscReadoutElement
Definition: CscReadoutElement.h:56
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
isValid
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
Definition: AtlasPID.h:812
ReadCondHandle.h
MuonGM::GeoModelCscTest::m_stPhi
MuonVal::ScalarBranch< short > & m_stPhi
Definition: GeoModelCscTest.h:55
MuonGM::GeoModelCscTest::m_stMultiLayer
MuonVal::ScalarBranch< short > & m_stMultiLayer
Definition: GeoModelCscTest.h:56
MuonGM::GeoModelCscTest::m_ALineRotZ
MuonVal::ScalarBranch< float > & m_ALineRotZ
Definition: GeoModelCscTest.h:67
MuonGM::GeoModelCscTest::initialize
StatusCode initialize() override
Definition: GeoModelCscTest.cxx:21
MuonGM::GeoModelCscTest::m_ALineRotT
MuonVal::ScalarBranch< float > & m_ALineRotT
Definition: GeoModelCscTest.h:66
MuonGM::GeoModelCscTest::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: GeoModelCscTest.h:38
MuonGM::GeoModelCscTest::m_ALineTransZ
MuonVal::ScalarBranch< float > & m_ALineTransZ
Definition: GeoModelCscTest.h:64
EventPrimitivesToStringConverter.h
MuonGM::GeoModelCscTest::m_layerTrans
MuonVal::CoordSystemsBranch m_layerTrans
Definition: GeoModelCscTest.h:70
MuonGM::MuonStation::getALine_rott
double getALine_rott() const
Definition: MuonStation.h:206
MuonGM::GeoModelCscTest::m_excludeStat
Gaudi::Property< std::vector< std::string > > m_excludeStat
Definition: GeoModelCscTest.h:49
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
MuonGM::CscReadoutElement::localToGlobalTransf
Amg::Transform3D localToGlobalTransf(const Identifier &id) const
Definition: CscReadoutElement.cxx:108
MuonGM::MuonReadoutElement::parentMuonStation
const MuonStation * parentMuonStation() const
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:136
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
MuonGM::MuonStation
Definition: MuonStation.h:51
CscReadoutElement.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MuonVal::VectorBranch::push_back
void push_back(const T &value)
Adds a new element at the end of the vector.
MuonGM::GeoModelCscTest::m_layNumber
MuonVal::VectorBranch< uint8_t > & m_layNumber
Definition: GeoModelCscTest.h:72
MuonGM::GeoModelCscTest::m_tree
MuonVal::MuonTesterTree m_tree
Definition: GeoModelCscTest.h:50
MuonGM::GeoModelCscTest::execute
StatusCode execute() override
Definition: GeoModelCscTest.cxx:88
MuonGM::GeoModelCscTest::finalize
StatusCode finalize() override
Definition: GeoModelCscTest.cxx:17
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
MuonGM::GeoModelCscTest::m_stIndex
MuonVal::ScalarBranch< unsigned short > & m_stIndex
Identifier of the readout element.
Definition: GeoModelCscTest.h:53
MuonGM::GeoModelCscTest::m_ALineRotS
MuonVal::ScalarBranch< float > & m_ALineRotS
Definition: GeoModelCscTest.h:65
MuonGM::MuonReadoutElement::getStationIndex
int getStationIndex() const
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:192
CscIdHelper
Definition: CscIdHelper.h:52
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
MuonGM::MuonReadoutElement::identify
Identifier identify() const override final
Returns the ATLAS Identifier of the MuonReadOutElement.
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:184
MuonVal::CoordSystemsBranch::push_back
void push_back(const Amg::Transform3D &trans)
Definition: CoordTransformBranch.cxx:28
MuonGM::GeoModelCscTest::m_detMgrKey
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_detMgrKey
MuonDetectorManager from the conditions store.
Definition: GeoModelCscTest.h:34
MuonVal::MuonTesterTree::fill
bool fill(const EventContext &ctx)
Fills the tree per call.
Definition: MuonTesterTree.cxx:89
MuonVal::MuonTesterTree::write
StatusCode write()
Finally write the TTree objects.
Definition: MuonTesterTree.cxx:178
MuonGM::CscReadoutElement::numberOfLayers
virtual int numberOfLayers(bool) const override final
number of layers in phi/eta projection
Definition: CscReadoutElement.h:328
MuonGM::MuonStation::hasALines
bool hasALines() const
Definition: MuonStation.h:207
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition: Control/CxxUtils/Root/StringUtils.cxx:85
MuonGM::GeoModelCscTest::dumpToTree
StatusCode dumpToTree(const EventContext &ctx, const CscReadoutElement *readoutEle)
Definition: GeoModelCscTest.cxx:115
MuonStation.h
MuonGM::MuonStation::getALine_rots
double getALine_rots() const
Definition: MuonStation.h:204
MuonGM::GeoModelCscTest::m_ALineTransT
MuonVal::ScalarBranch< float > & m_ALineTransT
Definition: GeoModelCscTest.h:63
MuonGM::MuonReadoutElement::getStationPhi
int getStationPhi() const
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:194
MuonGM::MuonReadoutElement::getStationEta
int getStationEta() const
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:193
MuonGM::GeoModelCscTest::m_testStations
std::set< Identifier > m_testStations
Set of stations to be tested.
Definition: GeoModelCscTest.h:42
Identifier
Definition: IdentifierFieldParser.cxx:14