Skip to content
Snippets Groups Projects
Commit 42bc4667 authored by Johannes Junggeburth's avatar Johannes Junggeburth :dog2: Committed by Julien Maurer
Browse files

MuonGeoModelTest - Add RPC, TGC tester algorithm and ALines for Mdt

MuonGeoModelTest - Add RPC, TGC tester algorithm and ALines for Mdt
parent 464f8d96
No related branches found
No related tags found
2 merge requests!641532023-07-05: Daily sweep of 23.0 into main,!64085MuonGeoModelTest - Add RPC, TGC tester algorithm and ALines for Mdt
...@@ -20,9 +20,9 @@ def SetupArgParser(): ...@@ -20,9 +20,9 @@ def SetupArgParser():
"OFLCOND-MC23-SDR-RUN3-02", "OFLCOND-MC23-SDR-RUN3-02",
"CONDBR2-BLKPA-2023-02", "CONDBR2-BLKPA-2023-02",
"CONDBR2-BLKPA-RUN2-11"]) "CONDBR2-BLKPA-RUN2-11"])
parser.add_argument("--chambers", default=["BIL1A3", #"BIS1A3", "EML1A8", "BOS1A8", "BML1A5" parser.add_argument("--chambers", default=["all"
], nargs="+", help="Chambers to check. If string is all, all chambers will be checked") ], nargs="+", help="Chambers to check. If string is all, all chambers will be checked")
parser.add_argument("--outRootFile", default="MdtGeoDump.root", help="Output ROOT file to dump the geomerty") parser.add_argument("--outRootFile", default="GeoModelDump.root", help="Output ROOT file to dump the geomerty")
parser.add_argument("--outTxtFile", default ="MdtGeoDump.txt", help="Output txt file to dump the geometry") parser.add_argument("--outTxtFile", default ="MdtGeoDump.txt", help="Output txt file to dump the geometry")
return parser return parser
...@@ -44,10 +44,25 @@ def setupHistSvc(flags, out_file="MdtGeoDump.root"): ...@@ -44,10 +44,25 @@ def setupHistSvc(flags, out_file="MdtGeoDump.root"):
def GeoModelMdtTestCfg(flags, name = "GeoModelMdtTest", **kwargs): def GeoModelMdtTestCfg(flags, name = "GeoModelMdtTest", **kwargs):
result = ComponentAccumulator() result = ComponentAccumulator()
if not flags.Detector.GeometryMDT: return result
the_alg = CompFactory.MuonGM.GeoModelMdtTest(name, **kwargs) the_alg = CompFactory.MuonGM.GeoModelMdtTest(name, **kwargs)
result.addEventAlgo(the_alg) result.addEventAlgo(the_alg)
return result return result
def GeoModelRpcTestCfg(flags,name = "GeoModelRpcTest", **kwargs):
result = ComponentAccumulator()
if not flags.Detector.GeometryRPC: return result
the_alg = CompFactory.MuonGM.GeoModelRpcTest(name, **kwargs)
result.addEventAlgo(the_alg)
return result
def GeoModelTgcTestCfg(flags, name = "GeoModelTgcTest", **kwargs):
result = ComponentAccumulator()
if not flags.Detector.GeometryTGC: return result
the_alg = CompFactory.MuonGM.GeoModelTgcTest(name, **kwargs)
result.addEventAlgo(the_alg)
return result
if __name__=="__main__": if __name__=="__main__":
from AthenaConfiguration.AllConfigFlags import initConfigFlags from AthenaConfiguration.AllConfigFlags import initConfigFlags
...@@ -68,6 +83,8 @@ if __name__=="__main__": ...@@ -68,6 +83,8 @@ if __name__=="__main__":
cfg.merge(GeoModelMdtTestCfg(flags, TestStations = args.chambers if len([x for x in args.chambers if x =="all"]) ==0 else [], cfg.merge(GeoModelMdtTestCfg(flags, TestStations = args.chambers if len([x for x in args.chambers if x =="all"]) ==0 else [],
DumpTxtFile = args.outTxtFile, DumpTxtFile = args.outTxtFile,
dumpSurfaces = True )) dumpSurfaces = True ))
cfg.merge(GeoModelRpcTestCfg(flags))
cfg.merge(GeoModelTgcTestCfg(flags))
cfg.printConfig(withDetails=True, summariseProps=True) cfg.printConfig(withDetails=True, summariseProps=True)
flags.dump() flags.dump()
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "EventPrimitives/EventPrimitivesToStringConverter.h" #include "EventPrimitives/EventPrimitivesToStringConverter.h"
#include "MuonReadoutGeometry/MdtReadoutElement.h" #include "MuonReadoutGeometry/MdtReadoutElement.h"
#include "MuonReadoutGeometry/MuonStation.h"
namespace MuonGM { namespace MuonGM {
GeoModelMdtTest::GeoModelMdtTest(const std::string& name, GeoModelMdtTest::GeoModelMdtTest(const std::string& name,
ISvcLocator* pSvcLocator) ISvcLocator* pSvcLocator)
...@@ -20,7 +21,6 @@ StatusCode GeoModelMdtTest::initialize() { ...@@ -20,7 +21,6 @@ StatusCode GeoModelMdtTest::initialize() {
if (m_dumpTree) ATH_CHECK(m_tree.init(this)); if (m_dumpTree) ATH_CHECK(m_tree.init(this));
const MdtIdHelper& id_helper{m_idHelperSvc->mdtIdHelper()}; const MdtIdHelper& id_helper{m_idHelperSvc->mdtIdHelper()};
for (const std::string& testCham : m_selectStat) { for (const std::string& testCham : m_selectStat) {
if (testCham.size() != 6) { if (testCham.size() != 6) {
ATH_MSG_FATAL("Wrong format given " << testCham); ATH_MSG_FATAL("Wrong format given " << testCham);
...@@ -123,6 +123,51 @@ StatusCode GeoModelMdtTest::dumpToTree(const EventContext& ctx, const MdtReadout ...@@ -123,6 +123,51 @@ StatusCode GeoModelMdtTest::dumpToTree(const EventContext& ctx, const MdtReadout
m_tubeRad = readoutEle->innerTubeRadius(); m_tubeRad = readoutEle->innerTubeRadius();
m_tubePitch = readoutEle->tubePitch(); m_tubePitch = readoutEle->tubePitch();
const MuonGM::MuonStation* station = readoutEle->parentMuonStation();
if (station->hasALines()){
m_ALineTransS = station->getALine_tras();
m_ALineTransT = station->getALine_traz();
m_ALineTransZ = station->getALine_trat();
m_ALineRotS = station->getALine_rots();
m_ALineRotT = station->getALine_rotz();
m_ALineRotZ = station->getALine_rott();
}
const BLinePar* bline = readoutEle->getBLinePar();
if (bline) {
m_BLineBz = bline->bz();
m_BLineBp = bline->bp();
m_BLineBn = bline->bn();
m_BLineSp = bline->sp();
m_BLineSn = bline->sn();
m_BLineTw = bline->tw();
m_BLinePg = bline->pg();
m_BLineTr = bline->tr();
m_BLineEg = bline->eg();
m_BLineEp = bline->ep();
m_BLineEn = bline->en();
}
if (station->hasMdtAsBuiltParams()) {
const MdtAsBuiltPar* asBuilt = station->getMdtAsBuiltParams();
using multilayer_t = MdtAsBuiltPar::multilayer_t;
using tubeSide_t = MdtAsBuiltPar::tubeSide_t;
const multilayer_t asBuiltMl = readoutEle->getMultilayer() ? multilayer_t::ML1 : multilayer_t::ML2;
m_asBuiltPosY0 = asBuilt->y0(asBuiltMl, tubeSide_t::POS);
m_asBuiltPosZ0 = asBuilt->z0(asBuiltMl, tubeSide_t::POS);
m_asBuiltPosAlpha = asBuilt->alpha (asBuiltMl, tubeSide_t::POS);
m_asBuiltPosPitchY = asBuilt->ypitch(asBuiltMl, tubeSide_t::POS);
m_asBuiltPosPitchZ = asBuilt->zpitch(asBuiltMl, tubeSide_t::POS);
m_asBuiltPosStagg = asBuilt->stagg (asBuiltMl, tubeSide_t::POS);
m_asBuiltNegY0 = asBuilt->y0(asBuiltMl, tubeSide_t::NEG);
m_asBuiltNegZ0 = asBuilt->z0(asBuiltMl, tubeSide_t::NEG);
m_asBuiltNegAlpha = asBuilt->alpha (asBuiltMl, tubeSide_t::NEG);
m_asBuiltNegPitchY = asBuilt->ypitch(asBuiltMl, tubeSide_t::NEG);
m_asBuiltNegPitchZ = asBuilt->zpitch(asBuiltMl, tubeSide_t::NEG);
m_asBuiltNegStagg = asBuilt->stagg (asBuiltMl, tubeSide_t::NEG);
}
const Amg::Transform3D& trans{readoutEle->transform()}; const Amg::Transform3D& trans{readoutEle->transform()};
m_readoutTransform.push_back(Amg::Vector3D(trans.translation())); m_readoutTransform.push_back(Amg::Vector3D(trans.translation()));
......
...@@ -52,9 +52,8 @@ class GeoModelMdtTest : public AthHistogramAlgorithm { ...@@ -52,9 +52,8 @@ class GeoModelMdtTest : public AthHistogramAlgorithm {
this, "TestStations", {"BIL1A3"}}; this, "TestStations", {"BIL1A3"}};
Gaudi::Property<std::string> m_outputTxt{ Gaudi::Property<std::string> m_outputTxt{
this, "DumpTxtFile", "MdtGeoDump.txt", this, "DumpTxtFile", "",
"Dump the basic informations from the Readout geometry into a txt " "Dump the basic informations from the Readout geometry into a txt file"};
"file"};
Gaudi::Property<bool> m_dumpSurfaces{this, "dumpSurfaces", false, "Adds the bounds and surfaces of each tube to the dump"}; Gaudi::Property<bool> m_dumpSurfaces{this, "dumpSurfaces", false, "Adds the bounds and surfaces of each tube to the dump"};
...@@ -109,6 +108,41 @@ class GeoModelMdtTest : public AthHistogramAlgorithm { ...@@ -109,6 +108,41 @@ class GeoModelMdtTest : public AthHistogramAlgorithm {
MuonVal::ThreeVectorBranch m_layDistColY{m_tree, "DistLayerLinearCol2"}; MuonVal::ThreeVectorBranch m_layDistColY{m_tree, "DistLayerLinearCol2"};
MuonVal::ThreeVectorBranch m_layDistColZ{m_tree, "DistLayerLinearCol3"}; MuonVal::ThreeVectorBranch m_layDistColZ{m_tree, "DistLayerLinearCol3"};
/// Alignment parameters
MuonVal::ScalarBranch<float>& m_ALineTransS{m_tree.newScalar<float>("ALineTransS", 0.)};
MuonVal::ScalarBranch<float>& m_ALineTransT{m_tree.newScalar<float>("ALineTransT", 0.)};
MuonVal::ScalarBranch<float>& m_ALineTransZ{m_tree.newScalar<float>("ALineTransZ", 0.)};
MuonVal::ScalarBranch<float>& m_ALineRotS{m_tree.newScalar<float>("ALineRotS", 0.)};
MuonVal::ScalarBranch<float>& m_ALineRotT{m_tree.newScalar<float>("ALineRotT", 0.)};
MuonVal::ScalarBranch<float>& m_ALineRotZ{m_tree.newScalar<float>("ALineRotZ", 0.)};
/// B Line chamber defomrations
MuonVal::ScalarBranch<float>& m_BLineBz{m_tree.newScalar<float>("BLineBz", 0.)};
MuonVal::ScalarBranch<float>& m_BLineBp{m_tree.newScalar<float>("BLineBp", 0.)};
MuonVal::ScalarBranch<float>& m_BLineBn{m_tree.newScalar<float>("BLineBn", 0.)};
MuonVal::ScalarBranch<float>& m_BLineSp{m_tree.newScalar<float>("BLineSp", 0.)};
MuonVal::ScalarBranch<float>& m_BLineSn{m_tree.newScalar<float>("BLineSn", 0.)};
MuonVal::ScalarBranch<float>& m_BLineTw{m_tree.newScalar<float>("BLineTw", 0.)};
MuonVal::ScalarBranch<float>& m_BLinePg{m_tree.newScalar<float>("BLinePg", 0.)};
MuonVal::ScalarBranch<float>& m_BLineTr{m_tree.newScalar<float>("BLineTr", 0.)};
MuonVal::ScalarBranch<float>& m_BLineEg{m_tree.newScalar<float>("BLineEg", 0.)};
MuonVal::ScalarBranch<float>& m_BLineEp{m_tree.newScalar<float>("BLineEp", 0.)};
MuonVal::ScalarBranch<float>& m_BLineEn{m_tree.newScalar<float>("BLineEn", 0.)};
/// AS-built parameters
MuonVal::ScalarBranch<float>& m_asBuiltPosY0{m_tree.newScalar<float>("AsBuiltPosY0", 0.)};
MuonVal::ScalarBranch<float>& m_asBuiltPosZ0{m_tree.newScalar<float>("AsBuiltPosZ0", 0.)};
MuonVal::ScalarBranch<float>& m_asBuiltPosAlpha{m_tree.newScalar<float>("AsBuiltPosAlpha", 0.)};
MuonVal::ScalarBranch<float>& m_asBuiltPosPitchY{m_tree.newScalar<float>("AsBuiltPosPitchY", 0.)};
MuonVal::ScalarBranch<float>& m_asBuiltPosPitchZ{m_tree.newScalar<float>("AsBuiltPosPitchZ", 0.)};
MuonVal::ScalarBranch<int> & m_asBuiltPosStagg{m_tree.newScalar<int>("AsBuiltPosStagg",0)};
MuonVal::ScalarBranch<float>& m_asBuiltNegY0{m_tree.newScalar<float>("AsBuiltNegY0", 0.)};
MuonVal::ScalarBranch<float>& m_asBuiltNegZ0{m_tree.newScalar<float>("AsBuiltNegZ0", 0.)};
MuonVal::ScalarBranch<float>& m_asBuiltNegAlpha{m_tree.newScalar<float>("AsBuiltNegAlpha", 0.)};
MuonVal::ScalarBranch<float>& m_asBuiltNegPitchY{m_tree.newScalar<float>("AsBuiltNegPitchY", 0.)};
MuonVal::ScalarBranch<float>& m_asBuiltNegPitchZ{m_tree.newScalar<float>("AsBuiltNegPitchZ", 0.)};
MuonVal::ScalarBranch<int> & m_asBuiltNegStagg{m_tree.newScalar<int>("AsBuiltNegStagg",0)};
}; };
} // namespace MuonGM } // namespace MuonGM
......
/*
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
*/
#include "GeoModelRpcTest.h"
#include <fstream>
#include <iostream>
#include "EventPrimitives/EventPrimitivesToStringConverter.h"
#include "MuonReadoutGeometry/RpcReadoutElement.h"
#include "MuonReadoutGeometry/MuonStation.h"
#include "StoreGate/ReadCondHandle.h"
namespace MuonGM {
GeoModelRpcTest::GeoModelRpcTest(const std::string& name, ISvcLocator* pSvcLocator):
AthHistogramAlgorithm{name, pSvcLocator} {}
StatusCode GeoModelRpcTest::finalize() {
if (m_dumpTree) ATH_CHECK(m_tree.write());
return StatusCode::SUCCESS;
}
StatusCode GeoModelRpcTest::initialize() {
ATH_CHECK(m_detMgrKey.initialize());
ATH_CHECK(m_idHelperSvc.retrieve());
if (m_dumpTree) ATH_CHECK(m_tree.init(this));
const RpcIdHelper& id_helper{m_idHelperSvc->rpcIdHelper()};
for (const std::string& testCham : m_selectStat) {
if (testCham.size() != 6) {
ATH_MSG_FATAL("Wrong format given " << testCham);
return StatusCode::FAILURE;
}
/// Example string BIL1A3
std::string statName = testCham.substr(0, 3);
unsigned int statEta = std::atoi(testCham.substr(3, 1).c_str()) *
(testCham[4] == 'A' ? 1 : -1);
unsigned int statPhi = std::atoi(testCham.substr(5, 1).c_str());
bool is_valid{false};
const Identifier eleId =
id_helper.elementID(statName, statEta, statPhi, is_valid);
if (!is_valid) {
ATH_MSG_FATAL("Failed to deduce a station name for " << testCham);
return StatusCode::FAILURE;
}
m_testStations.insert(eleId);
}
/// Add all stations for testing
if (m_testStations.empty()){
for(auto itr = id_helper.detectorElement_begin();
itr!= id_helper.detectorElement_end();++itr){
m_testStations.insert(*itr);
}
}
return StatusCode::SUCCESS;
}
StatusCode GeoModelRpcTest::execute() {
const EventContext& ctx{Gaudi::Hive::currentContext()};
SG::ReadCondHandle<MuonDetectorManager> detMgr{m_detMgrKey, ctx};
if (!detMgr.isValid()) {
ATH_MSG_FATAL("Failed to retrieve MuonDetectorManager "
<< m_detMgrKey.fullKey());
return StatusCode::FAILURE;
}
std::optional<std::fstream> outStream{};
if (!m_outputTxt.empty()) {
outStream = std::make_optional<std::fstream>(m_outputTxt, std::ios_base::out);
if (!outStream->good()) {
ATH_MSG_FATAL("Failed to create output file " << m_outputTxt);
return StatusCode::FAILURE;
}
}
for (const Identifier& test_me : m_testStations) {
ATH_MSG_VERBOSE("Test retrieval of Mdt detector element "
<< m_idHelperSvc->toStringDetEl(test_me));
const RpcReadoutElement* reElement = detMgr->getRpcReadoutElement(test_me);
if (!reElement) {
ATH_MSG_VERBOSE("Detector element is invalid");
continue;
}
/// Check that we retrieved the proper readout element
if (reElement->identify() != test_me) {
ATH_MSG_FATAL("Expected to retrieve "
<< m_idHelperSvc->toStringDetEl(test_me) << ". But got instead "
<< m_idHelperSvc->toStringDetEl(reElement->identify()));
return StatusCode::FAILURE;
}
ATH_CHECK(dumpToTree(ctx, reElement));
}
return StatusCode::SUCCESS;
}
StatusCode GeoModelRpcTest::dumpToTree(const EventContext& ctx, const RpcReadoutElement* readoutEle) {
m_stIndex = readoutEle->getStationIndex();
m_stEta = readoutEle->getStationEta();
m_stPhi = readoutEle->getStationPhi();
m_doubletR = readoutEle->getDoubletR();
m_doubletZ = readoutEle->getDoubletZ();
m_doubletPhi = readoutEle->getDoubletPhi();
const RpcIdHelper& idHelper{m_idHelperSvc->rpcIdHelper()};
const Amg::Transform3D& trans{readoutEle->transform()};
m_readoutTransform.push_back(Amg::Vector3D(trans.translation()));
m_readoutTransform.push_back(Amg::Vector3D(trans.linear()*Amg::Vector3D::UnitX()));
m_readoutTransform.push_back(Amg::Vector3D(trans.linear()*Amg::Vector3D::UnitY()));
m_readoutTransform.push_back(Amg::Vector3D(trans.linear()*Amg::Vector3D::UnitX()));
const MuonGM::MuonStation* station = readoutEle->parentMuonStation();
if (station->hasALines()){
m_ALineTransS = station->getALine_tras();
m_ALineTransT = station->getALine_traz();
m_ALineTransZ = station->getALine_trat();
m_ALineRotS = station->getALine_rots();
m_ALineRotT = station->getALine_rotz();
m_ALineRotZ = station->getALine_rott();
}
for (bool measPhi : {false, true}) {
for (int layer = 1 ; layer <= readoutEle->numberOfLayers(); ++layer){
const Identifier id = idHelper.panelID(readoutEle->identify(),layer, measPhi);
const Amg::Transform3D layerTransform = readoutEle->localToGlobalTransf(id);
m_layCenter.push_back(layerTransform.translation());
m_layTransColX.push_back(layerTransform.linear()*Amg::Vector3D::UnitX());
m_layTransColY.push_back(layerTransform.linear()*Amg::Vector3D::UnitY());
m_layTransColZ.push_back(layerTransform.linear()*Amg::Vector3D::UnitZ());
m_layMeasPhi.push_back(measPhi);
m_layNumber.push_back(layer);
}
}
return m_tree.fill(ctx) ? StatusCode::SUCCESS : StatusCode::FAILURE;
}
}
\ No newline at end of file
/*
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
*/
#ifndef MUONGEOMODELTESTR4_GEOMODELRPCTEST_H
#define MUONGEOMODELTESTR4_GEOMODELRPCTEST_H
#include <AthenaBaseComps/AthHistogramAlgorithm.h>
#include <MuonIdHelpers/IMuonIdHelperSvc.h>
#include <set>
#include "MuonReadoutGeometry/MuonDetectorManager.h"
#include "MuonReadoutGeometry/RpcReadoutElement.h"
#include "StoreGate/ReadCondHandleKey.h"
#include "MuonTesterTree/MuonTesterTree.h"
#include "MuonTesterTree/IdentifierBranch.h"
#include "MuonTesterTree/ThreeVectorBranch.h"
namespace MuonGM {
class GeoModelRpcTest : public AthHistogramAlgorithm {
public:
GeoModelRpcTest(const std::string& name, ISvcLocator* pSvcLocator);
StatusCode initialize() override;
StatusCode execute() override;
StatusCode finalize() override;
unsigned int cardinality() const override final { return 1; }
private:
StatusCode dumpToTree(const EventContext& ctx, const RpcReadoutElement* readoutEle);
/// MuonDetectorManager from the conditions store
SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_detMgrKey{
this, "DetectorManagerKey", "MuonDetectorManager",
"Key of input MuonDetectorManager condition data"};
ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc{
this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
/// Set of stations to be tested
std::set<Identifier> m_testStations{};
/// String should be formated like
/// <stationName><stationEta><A/C><stationPhi>
Gaudi::Property<std::vector<std::string>> m_selectStat{
this, "TestStations", {}, "Constrain the stations to be tested"};
Gaudi::Property<std::string> m_outputTxt{
this, "DumpTxtFile", "",
"Dump the basic informations from the Readout geometry into a txt "};
/// Write a TTree for validation purposes
Gaudi::Property<bool> m_dumpTree{this, "writeTTree", true};
MuonVal::MuonTesterTree m_tree{"RpcGeoModelTree", "GEOMODELTESTER"};
/// Identifier of the readout element
MuonVal::ScalarBranch<unsigned short>& m_stIndex{m_tree.newScalar<unsigned short>("stationIndex")};
MuonVal::ScalarBranch<short>& m_stEta{m_tree.newScalar<short>("stationEta")};
MuonVal::ScalarBranch<short>& m_stPhi{m_tree.newScalar<short>("stationPhi")};
MuonVal::ScalarBranch<uint8_t>& m_doubletR{m_tree.newScalar<uint8_t>("stationDoubletR")};
MuonVal::ScalarBranch<uint8_t>& m_doubletZ{m_tree.newScalar<uint8_t>("stationDoubletZ")};
MuonVal::ScalarBranch<uint8_t>& m_doubletPhi{m_tree.newScalar<uint8_t>("stationDoubletPhi")};
/// Transformation of the readout element (Translation, ColX, ColY, ColZ)
MuonVal::ThreeVectorBranch m_readoutTransform{m_tree, "ElementTransform"};
/// Alignment parameters
MuonVal::ScalarBranch<float>& m_ALineTransS{m_tree.newScalar<float>("ALineTransS", 0.)};
MuonVal::ScalarBranch<float>& m_ALineTransT{m_tree.newScalar<float>("ALineTransT", 0.)};
MuonVal::ScalarBranch<float>& m_ALineTransZ{m_tree.newScalar<float>("ALineTransZ", 0.)};
MuonVal::ScalarBranch<float>& m_ALineRotS{m_tree.newScalar<float>("ALineRotS", 0.)};
MuonVal::ScalarBranch<float>& m_ALineRotT{m_tree.newScalar<float>("ALineRotT", 0.)};
MuonVal::ScalarBranch<float>& m_ALineRotZ{m_tree.newScalar<float>("ALineRotZ", 0.)};
MuonVal::ThreeVectorBranch m_layCenter{m_tree,"LayerCenter"};
MuonVal::ThreeVectorBranch m_layTransColX{m_tree, "LayerLinearCol1"};
MuonVal::ThreeVectorBranch m_layTransColY{m_tree, "LayerLinearCol2"};
MuonVal::ThreeVectorBranch m_layTransColZ{m_tree, "LayerLinearCol3"};
MuonVal::VectorBranch<bool>& m_layMeasPhi{m_tree.newVector<bool>("LayerMeasPhi")};
MuonVal::VectorBranch<uint8_t>& m_layNumber{m_tree.newVector<uint8_t>("LayerNumber")};
};
}
#endif
\ No newline at end of file
/*
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
*/
#include "GeoModelTgcTest.h"
#include <fstream>
#include <iostream>
#include "EventPrimitives/EventPrimitivesToStringConverter.h"
#include "MuonReadoutGeometry/TgcReadoutElement.h"
#include "MuonReadoutGeometry/MuonStation.h"
#include "StoreGate/ReadCondHandle.h"
namespace MuonGM {
GeoModelTgcTest::GeoModelTgcTest(const std::string& name, ISvcLocator* pSvcLocator):
AthHistogramAlgorithm{name, pSvcLocator} {}
StatusCode GeoModelTgcTest::finalize() {
if (m_dumpTree) ATH_CHECK(m_tree.write());
return StatusCode::SUCCESS;
}
StatusCode GeoModelTgcTest::initialize() {
ATH_CHECK(m_detMgrKey.initialize());
ATH_CHECK(m_idHelperSvc.retrieve());
if (m_dumpTree) ATH_CHECK(m_tree.init(this));
const TgcIdHelper& id_helper{m_idHelperSvc->tgcIdHelper()};
for (const std::string& testCham : m_selectStat) {
if (testCham.size() != 6) {
ATH_MSG_FATAL("Wrong format given " << testCham);
return StatusCode::FAILURE;
}
/// Example string BIL1A3
std::string statName = testCham.substr(0, 3);
unsigned int statEta = std::atoi(testCham.substr(3, 1).c_str()) *
(testCham[4] == 'A' ? 1 : -1);
unsigned int statPhi = std::atoi(testCham.substr(5, 1).c_str());
bool is_valid{false};
const Identifier eleId =
id_helper.elementID(statName, statEta, statPhi, is_valid);
if (!is_valid) {
ATH_MSG_FATAL("Failed to deduce a station name for " << testCham);
return StatusCode::FAILURE;
}
m_testStations.insert(eleId);
}
/// Add all stations for testing
if (m_testStations.empty()){
for(auto itr = id_helper.detectorElement_begin();
itr!= id_helper.detectorElement_end();++itr){
m_testStations.insert(*itr);
}
}
return StatusCode::SUCCESS;
}
StatusCode GeoModelTgcTest::execute() {
const EventContext& ctx{Gaudi::Hive::currentContext()};
SG::ReadCondHandle<MuonDetectorManager> detMgr{m_detMgrKey, ctx};
if (!detMgr.isValid()) {
ATH_MSG_FATAL("Failed to retrieve MuonDetectorManager "
<< m_detMgrKey.fullKey());
return StatusCode::FAILURE;
}
std::optional<std::fstream> outStream{};
if (!m_outputTxt.empty()) {
outStream = std::make_optional<std::fstream>(m_outputTxt, std::ios_base::out);
if (!outStream->good()) {
ATH_MSG_FATAL("Failed to create output file " << m_outputTxt);
return StatusCode::FAILURE;
}
}
for (const Identifier& test_me : m_testStations) {
ATH_MSG_VERBOSE("Test retrieval of Mdt detector element "
<< m_idHelperSvc->toStringDetEl(test_me));
const TgcReadoutElement* reElement = detMgr->getTgcReadoutElement(test_me);
if (!reElement) {
ATH_MSG_VERBOSE("Detector element is invalid");
continue;
}
/// Check that we retrieved the proper readout element
if (reElement->identify() != test_me) {
ATH_MSG_FATAL("Expected to retrieve "
<< m_idHelperSvc->toStringDetEl(test_me) << ". But got instead "
<< m_idHelperSvc->toStringDetEl(reElement->identify()));
return StatusCode::FAILURE;
}
ATH_CHECK(dumpToTree(ctx, reElement));
}
return StatusCode::SUCCESS;
}
StatusCode GeoModelTgcTest::dumpToTree(const EventContext& ctx, const TgcReadoutElement* readoutEle) {
m_stIndex = readoutEle->getStationIndex();
m_stEta = readoutEle->getStationEta();
m_stPhi = readoutEle->getStationPhi();
const TgcIdHelper& idHelper{m_idHelperSvc->tgcIdHelper()};
const Amg::Transform3D& trans{readoutEle->transform()};
m_readoutTransform.push_back(Amg::Vector3D(trans.translation()));
m_readoutTransform.push_back(Amg::Vector3D(trans.linear()*Amg::Vector3D::UnitX()));
m_readoutTransform.push_back(Amg::Vector3D(trans.linear()*Amg::Vector3D::UnitY()));
m_readoutTransform.push_back(Amg::Vector3D(trans.linear()*Amg::Vector3D::UnitX()));
const MuonGM::MuonStation* station = readoutEle->parentMuonStation();
if (station->hasALines()){
m_ALineTransS = station->getALine_tras();
m_ALineTransT = station->getALine_traz();
m_ALineTransZ = station->getALine_trat();
m_ALineRotS = station->getALine_rots();
m_ALineRotT = station->getALine_rotz();
m_ALineRotZ = station->getALine_rott();
}
for (bool measPhi : {false, true}) {
for (int layer = 1 ; layer <= readoutEle->numberOfLayers(measPhi); ++layer){
const Identifier id = idHelper.channelID(readoutEle->identify(),layer, measPhi,1);
const Amg::Transform3D layerTransform = readoutEle->localToGlobalTransf(id);
m_layCenter.push_back(layerTransform.translation());
m_layTransColX.push_back(layerTransform.linear()*Amg::Vector3D::UnitX());
m_layTransColY.push_back(layerTransform.linear()*Amg::Vector3D::UnitY());
m_layTransColZ.push_back(layerTransform.linear()*Amg::Vector3D::UnitZ());
m_layMeasPhi.push_back(measPhi);
m_layNumber.push_back(layer);
}
}
return m_tree.fill(ctx) ? StatusCode::SUCCESS : StatusCode::FAILURE;
}
}
\ No newline at end of file
/*
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
*/
#ifndef MUONGEOMODELTESTR4_GEOMODELRTGCTEST_H
#define MUONGEOMODELTESTR4_GEOMODELRTGCTEST_H
#include <AthenaBaseComps/AthHistogramAlgorithm.h>
#include <MuonIdHelpers/IMuonIdHelperSvc.h>
#include <set>
#include "MuonReadoutGeometry/MuonDetectorManager.h"
#include "MuonReadoutGeometry/TgcReadoutElement.h"
#include "StoreGate/ReadCondHandleKey.h"
#include "MuonTesterTree/MuonTesterTree.h"
#include "MuonTesterTree/IdentifierBranch.h"
#include "MuonTesterTree/ThreeVectorBranch.h"
namespace MuonGM {
class GeoModelTgcTest : public AthHistogramAlgorithm {
public:
GeoModelTgcTest(const std::string& name, ISvcLocator* pSvcLocator);
StatusCode initialize() override;
StatusCode execute() override;
StatusCode finalize() override;
unsigned int cardinality() const override final { return 1; }
private:
StatusCode dumpToTree(const EventContext& ctx, const TgcReadoutElement* readoutEle);
/// MuonDetectorManager from the conditions store
SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_detMgrKey{
this, "DetectorManagerKey", "MuonDetectorManager",
"Key of input MuonDetectorManager condition data"};
ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc{
this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
/// Set of stations to be tested
std::set<Identifier> m_testStations{};
/// String should be formated like
/// <stationName><stationEta><A/C><stationPhi>
Gaudi::Property<std::vector<std::string>> m_selectStat{
this, "TestStations", {}, "Constrain the stations to be tested"};
Gaudi::Property<std::string> m_outputTxt{
this, "DumpTxtFile", "TgcGeoDump.txt",
"Dump the basic informations from the Readout geometry into a txt "
"file"};
/// Write a TTree for validation purposes
Gaudi::Property<bool> m_dumpTree{this, "writeTTree", true};
MuonVal::MuonTesterTree m_tree{"TgcGeoModelTree", "GEOMODELTESTER"};
/// Identifier of the readout element
MuonVal::ScalarBranch<unsigned short>& m_stIndex{m_tree.newScalar<unsigned short>("stationIndex")};
MuonVal::ScalarBranch<short>& m_stEta{m_tree.newScalar<short>("stationEta")};
MuonVal::ScalarBranch<short>& m_stPhi{m_tree.newScalar<short>("stationPhi")};
/// Transformation of the readout element (Translation, ColX, ColY, ColZ)
MuonVal::ThreeVectorBranch m_readoutTransform{m_tree, "ElementTransform"};
/// Alignment parameters
MuonVal::ScalarBranch<float>& m_ALineTransS{m_tree.newScalar<float>("ALineTransS", 0.)};
MuonVal::ScalarBranch<float>& m_ALineTransT{m_tree.newScalar<float>("ALineTransT", 0.)};
MuonVal::ScalarBranch<float>& m_ALineTransZ{m_tree.newScalar<float>("ALineTransZ", 0.)};
MuonVal::ScalarBranch<float>& m_ALineRotS{m_tree.newScalar<float>("ALineRotS", 0.)};
MuonVal::ScalarBranch<float>& m_ALineRotT{m_tree.newScalar<float>("ALineRotT", 0.)};
MuonVal::ScalarBranch<float>& m_ALineRotZ{m_tree.newScalar<float>("ALineRotZ", 0.)};
MuonVal::ThreeVectorBranch m_layCenter{m_tree,"LayerCenter"};
MuonVal::ThreeVectorBranch m_layTransColX{m_tree, "LayerLinearCol1"};
MuonVal::ThreeVectorBranch m_layTransColY{m_tree, "LayerLinearCol2"};
MuonVal::ThreeVectorBranch m_layTransColZ{m_tree, "LayerLinearCol3"};
MuonVal::VectorBranch<bool>& m_layMeasPhi{m_tree.newVector<bool>("LayerMeasPhi")};
MuonVal::VectorBranch<uint8_t>& m_layNumber{m_tree.newVector<uint8_t>("LayerNumber")};
};
}
#endif
\ No newline at end of file
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
*/ */
#include "../GeoModelMdtTest.h" #include "../GeoModelMdtTest.h"
#include "../GeoModelRpcTest.h"
#include "../GeoModelTgcTest.h"
#include "../NSWGeoPlottingAlg.h" #include "../NSWGeoPlottingAlg.h"
#include "MuonGeoModelTest/MuonGMCheck.h" #include "MuonGeoModelTest/MuonGMCheck.h"
#include "MuonGeoModelTest/MuonGMTestOnPrd.h" #include "MuonGeoModelTest/MuonGMTestOnPrd.h"
...@@ -13,3 +15,5 @@ DECLARE_COMPONENT(MuonGMTestOnPrd) ...@@ -13,3 +15,5 @@ DECLARE_COMPONENT(MuonGMTestOnPrd)
DECLARE_COMPONENT(MuonHitRelocation) DECLARE_COMPONENT(MuonHitRelocation)
DECLARE_COMPONENT(NSWGeoPlottingAlg) DECLARE_COMPONENT(NSWGeoPlottingAlg)
DECLARE_COMPONENT(MuonGM::GeoModelMdtTest) DECLARE_COMPONENT(MuonGM::GeoModelMdtTest)
DECLARE_COMPONENT(MuonGM::GeoModelRpcTest)
DECLARE_COMPONENT(MuonGM::GeoModelTgcTest)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment