ATLAS Offline Software
GeoModelCscTest.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 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 
17 GeoModelCscTest::GeoModelCscTest(const std::string& name, ISvcLocator* pSvcLocator):
18  AthHistogramAlgorithm{name, pSvcLocator} {}
19 
22  return StatusCode::SUCCESS;
23 }
26  ATH_CHECK(m_idHelperSvc.retrieve());
27  ATH_CHECK(m_tree.init(this));
28  const CscIdHelper& id_helper{m_idHelperSvc->cscIdHelper()};
29  for (const std::string& testCham : m_selectStat) {
30  if (testCham.size() != 6) {
31  ATH_MSG_FATAL("Wrong format given " << testCham);
32  return StatusCode::FAILURE;
33  }
35  std::string statName = testCham.substr(0, 3);
36  unsigned int statEta = std::atoi(testCham.substr(3, 1).c_str()) *
37  (testCham[4] == 'A' ? 1 : -1);
38  unsigned int statPhi = std::atoi(testCham.substr(5, 1).c_str());
39  bool is_valid{false};
40  const Identifier eleId =
41  id_helper.elementID(statName, statEta, statPhi, is_valid);
42  if (!is_valid) {
43  ATH_MSG_FATAL("Failed to deduce a station name for " << testCham);
44  return StatusCode::FAILURE;
45  }
46  m_testStations.insert(eleId);
47  }
49  if (m_testStations.empty()){
50  for(auto itr = id_helper.detectorElement_begin();
51  itr!= id_helper.detectorElement_end();++itr){
52  m_testStations.insert(*itr);
53  }
54  }
55  return StatusCode::SUCCESS;
56 }
58  const EventContext& ctx{Gaudi::Hive::currentContext()};
60  if (!detMgr.isValid()) {
61  ATH_MSG_FATAL("Failed to retrieve MuonDetectorManager "
62  << m_detMgrKey.fullKey());
63  return StatusCode::FAILURE;
64  }
65  for (const Identifier& test_me : m_testStations) {
66  ATH_MSG_VERBOSE("Test retrieval of Mdt detector element "
67  << m_idHelperSvc->toStringDetEl(test_me));
68  const CscReadoutElement* reElement = detMgr->getCscReadoutElement(test_me);
69  if (!reElement) {
70  ATH_MSG_VERBOSE("Detector element is invalid");
71  continue;
72  }
74  if (reElement->identify() != test_me) {
75  ATH_MSG_FATAL("Expected to retrieve "
76  << m_idHelperSvc->toStringDetEl(test_me) << ". But got instead "
77  << m_idHelperSvc->toStringDetEl(reElement->identify()));
78  return StatusCode::FAILURE;
79  }
80  ATH_CHECK(dumpToTree(ctx, reElement));
81  }
82  return StatusCode::SUCCESS;
83 }
84 StatusCode GeoModelCscTest::dumpToTree(const EventContext& ctx, const CscReadoutElement* readoutEle) {
85  m_stIndex = readoutEle->getStationIndex();
86  m_stEta = readoutEle->getStationEta();
87  m_stPhi = readoutEle->getStationPhi();
88  m_stMultiLayer = readoutEle->ChamberLayer();
89 
90  const CscIdHelper& idHelper{m_idHelperSvc->cscIdHelper()};
91 
92  const Amg::Transform3D& trans{readoutEle->transform()};
93  m_readoutTransform = trans;
94 
95  const MuonGM::MuonStation* station = readoutEle->parentMuonStation();
96  if (station->hasALines()){
97  m_ALineTransS = station->getALine_tras();
98  m_ALineTransT = station->getALine_traz();
99  m_ALineTransZ = station->getALine_trat();
100  m_ALineRotS = station->getALine_rots();
101  m_ALineRotT = station->getALine_rotz();
102  m_ALineRotZ = station->getALine_rott();
103  }
104  for (bool measPhi : {false, true}) {
105  for (int layer = 1 ; layer <= readoutEle->numberOfLayers(measPhi); ++layer){
106  const Identifier id = idHelper.channelID(readoutEle->identify(),readoutEle->ChamberLayer(),layer, measPhi,1);
107  m_layerTrans.push_back(readoutEle->localToGlobalTransf(id));
108  m_layMeasPhi.push_back(measPhi);
110  }
111  }
112  return m_tree.fill(ctx) ? StatusCode::SUCCESS : StatusCode::FAILURE;
113 }
114 
115 
116 }
MuonGM::GeoModelCscTest::m_ALineTransS
MuonVal::ScalarBranch< float > & m_ALineTransS
Alignment parameters.
Definition: GeoModelCscTest.h:60
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:45
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:192
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
MuonVal::MuonTesterTree::init
StatusCode init(OWNER *instance)
Initialize method.
MuonGM::GeoModelCscTest::m_stEta
MuonVal::ScalarBranch< short > & m_stEta
Definition: GeoModelCscTest.h:52
MuonGM::MuonStation::getALine_rotz
double getALine_rotz() const
Definition: MuonStation.h:194
MuonGM::MuonStation::getALine_traz
double getALine_traz() const
Definition: MuonStation.h:191
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:57
MuonGM::MuonStation::getALine_tras
double getALine_tras() const
Definition: MuonStation.h:190
MuonGM::GeoModelCscTest::m_layMeasPhi
MuonVal::VectorBranch< bool > & m_layMeasPhi
Definition: GeoModelCscTest.h:69
GeoModelCscTest.h
MuonGM::CscReadoutElement
Definition: CscReadoutElement.h:56
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
ReadCondHandle.h
MuonGM::GeoModelCscTest::m_stPhi
MuonVal::ScalarBranch< short > & m_stPhi
Definition: GeoModelCscTest.h:53
MuonGM::GeoModelCscTest::m_stMultiLayer
MuonVal::ScalarBranch< short > & m_stMultiLayer
Definition: GeoModelCscTest.h:54
MuonGM::GeoModelCscTest::m_ALineRotZ
MuonVal::ScalarBranch< float > & m_ALineRotZ
Definition: GeoModelCscTest.h:65
MuonGM::GeoModelCscTest::initialize
StatusCode initialize() override
Definition: GeoModelCscTest.cxx:24
MuonGM::GeoModelCscTest::m_ALineRotT
MuonVal::ScalarBranch< float > & m_ALineRotT
Definition: GeoModelCscTest.h:64
MuonGM::GeoModelCscTest::GeoModelCscTest
GeoModelCscTest(const std::string &name, ISvcLocator *pSvcLocator)
Definition: GeoModelCscTest.cxx:17
MuonGM::GeoModelCscTest::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: GeoModelCscTest.h:37
MuonGM::GeoModelCscTest::m_ALineTransZ
MuonVal::ScalarBranch< float > & m_ALineTransZ
Definition: GeoModelCscTest.h:62
EventPrimitivesToStringConverter.h
MuonGM::GeoModelCscTest::m_layerTrans
MuonVal::CoordSystemsBranch m_layerTrans
Definition: GeoModelCscTest.h:68
MuonGM::MuonStation::getALine_rott
double getALine_rott() const
Definition: MuonStation.h:195
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:135
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
AthHistogramAlgorithm
Definition: AthHistogramAlgorithm.h:32
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:70
MuonGM::GeoModelCscTest::m_tree
MuonVal::MuonTesterTree m_tree
Definition: GeoModelCscTest.h:48
MuonGM::GeoModelCscTest::execute
StatusCode execute() override
Definition: GeoModelCscTest.cxx:57
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
MuonGM::GeoModelCscTest::finalize
StatusCode finalize() override
Definition: GeoModelCscTest.cxx:20
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:51
MuonGM::GeoModelCscTest::m_ALineRotS
MuonVal::ScalarBranch< float > & m_ALineRotS
Definition: GeoModelCscTest.h:63
MuonGM::MuonReadoutElement::getStationIndex
int getStationIndex() const
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:192
CscIdHelper
Definition: CscIdHelper.h:52
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:33
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:196
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:84
MuonStation.h
MuonGM::MuonStation::getALine_rots
double getALine_rots() const
Definition: MuonStation.h:193
MuonGM::GeoModelCscTest::m_ALineTransT
MuonVal::ScalarBranch< float > & m_ALineTransT
Definition: GeoModelCscTest.h:61
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:41
Identifier
Definition: IdentifierFieldParser.cxx:14