Skip to content
Snippets Groups Projects
Commit 7a5da201 authored by Adam Edward Barton's avatar Adam Edward Barton
Browse files

Merge branch 'SpacePointCsv' into 'main'

MuonCsvConverter - Use space point to retrieve position in chamber

See merge request atlas/athena!70655
parents 9f1307e4 f9431c85
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,7 @@ atlas_add_component( MuonHitCsvDump
src/components/*.cxx
LINK_LIBRARIES AthenaBaseComps GeoPrimitives MuonIdHelpersLib
MuonSimEvent xAODMuonSimHit StoreGateLib MdtCalibSvcLib
xAODMuonPrepData)
xAODMuonPrepData MuonSpacePoint)
atlas_install_python_modules( python/*.py)
......
......@@ -5,6 +5,7 @@
#include "MdtDriftCircleCsvDumperAlg.h"
#include "xAODMuonPrepData/MdtDriftCircleContainer.h"
#include "MuonSpacePoint/MuonSpacePoint.h"
#include "MuonIdHelpers/IMuonIdHelperSvc.h"
#include<fstream>
......@@ -15,6 +16,7 @@ MdtDriftCircleCsvDumperAlg::MdtDriftCircleCsvDumperAlg(const std::string& name,
AthAlgorithm{name, pSvcLocator} {}
StatusCode MdtDriftCircleCsvDumperAlg::initialize(){
ATH_CHECK(m_geoCtxKey.initialize());
ATH_CHECK(m_inDriftCircleKey.initialize());
ATH_CHECK(m_idHelperSvc.retrieve());
return StatusCode::SUCCESS;
......@@ -40,11 +42,19 @@ MdtDriftCircleCsvDumperAlg::MdtDriftCircleCsvDumperAlg(const std::string& name,
SG::ReadHandle<xAOD::MdtDriftCircleContainer> readDriftCircles{m_inDriftCircleKey, context};
ATH_CHECK(readDriftCircles.isPresent());
SG::ReadHandle<ActsGeometryContext> gctxHandle{m_geoCtxKey, context};
ATH_CHECK(gctxHandle.isPresent());
const ActsGeometryContext& gctx{*gctxHandle};
const MdtIdHelper& mdtHelper{m_idHelperSvc->mdtIdHelper()};
for(const xAOD::MdtDriftCircle* driftCircle : *readDriftCircles){
const Amg::Vector3D tubePos{xAOD::toEigen(driftCircle->tubePosInStation())};
const Identifier tubeId{(Identifier::value_type)driftCircle->identifier()};
const MuonR4::MuonSpacePoint spacePoint{gctx, driftCircle};
const Amg::Vector3D& tubePos{spacePoint.positionInChamber()};
const Identifier& tubeId{spacePoint.identify()};
file<<driftCircle->driftRadius()<<delim;
file<<tubePos.x()<<delim;
file<<tubePos.y()<<delim;
......
......@@ -5,9 +5,10 @@
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
#include<string>
#include <AthenaBaseComps/AthAlgorithm.h>
#include <ActsGeometryInterfaces/ActsGeometryContext.h>
#include <MuonIdHelpers/IMuonIdHelperSvc.h>
#include <StoreGate/ReadHandleKey.h>
......@@ -27,7 +28,8 @@ class MdtDriftCircleCsvDumperAlg: public AthAlgorithm {
StatusCode execute() override;
private:
SG::ReadHandleKey<ActsGeometryContext> m_geoCtxKey{this, "AlignmentKey", "ActsAlignment", "cond handle key"};
// drift circles in xAOD format
SG::ReadHandleKey<xAOD::MdtDriftCircleContainer> m_inDriftCircleKey{
this, "DriftCircleKey", "xAODMdtCircles", "mdt circle container"};
......
......@@ -27,6 +27,7 @@ MuonSimHitCsvDumperAlg::MuonSimHitCsvDumperAlg(const std::string& name, ISvcLoca
AthAlgorithm{name, pSvcLocator} {}
StatusCode MuonSimHitCsvDumperAlg::initialize() {
ATH_CHECK(m_geoCtxKey.initialize());
ATH_CHECK(m_inSimHitKey.initialize());
ATH_CHECK(m_idHelperSvc.retrieve());
ATH_CHECK(detStore()->retrieve(m_r4DetMgr));
......@@ -35,8 +36,11 @@ StatusCode MuonSimHitCsvDumperAlg::initialize() {
}
StatusCode MuonSimHitCsvDumperAlg::execute(){
const ActsGeometryContext gctx{};
const EventContext & context = Gaudi::Hive::currentContext();
SG::ReadHandle<ActsGeometryContext> gctxHandle{m_geoCtxKey, context};
ATH_CHECK(gctxHandle.isPresent());
const ActsGeometryContext& gctx{*gctxHandle};
// these are the conventions by ACTS
std::ofstream file{std::string(Form("event%09zu-",++m_event))+"MuonSimHit.csv"};
......@@ -52,7 +56,7 @@ StatusCode MuonSimHitCsvDumperAlg::execute(){
file<<"LocalDirectiony"<<delim;
file<<"LocalDirectionz"<<std::endl;
const EventContext & context = Gaudi::Hive::currentContext();
std::set<TrueHitInChamb> usedStations{};
for (const SG::ReadHandleKey<xAOD::MuonSimHitContainer>& key : m_inSimHitKey) {
......
......@@ -28,6 +28,7 @@ class MuonSimHitCsvDumperAlg: public AthAlgorithm {
private:
SG::ReadHandleKey<ActsGeometryContext> m_geoCtxKey{this, "AlignmentKey", "ActsAlignment", "cond handle key"};
SG::ReadHandleKeyArray<xAOD::MuonSimHitContainer> m_inSimHitKey{
this, "MuonSimHitKey",{}, "List of sim hit containers"};
......@@ -36,7 +37,7 @@ class MuonSimHitCsvDumperAlg: public AthAlgorithm {
this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
/// Access to the readout geometry
const MuonGMR4::MuonDetectorManager* m_r4DetMgr{nullptr};
const MuonGMR4::MuonDetectorManager* m_r4DetMgr{nullptr};
size_t m_event{0};
};
......
......@@ -3,10 +3,7 @@
*/
#include "MuonStripCsvDumperAlg.h"
#include "MuonReadoutGeometryR4/MuonChamber.h"
#include "xAODMuonPrepData/RpcStrip.h"
#include "xAODMuonPrepData/TgcStrip.h"
#include "xAODMuonPrepData/MMCluster.h"
#include "MuonSpacePoint/MuonSpacePoint.h"
#include "StoreGate/ReadHandle.h"
#include <fstream>
#include <TString.h>
......@@ -17,6 +14,7 @@ MuonStripCsvDumperAlg::MuonStripCsvDumperAlg(const std::string& name, ISvcLocato
StatusCode MuonStripCsvDumperAlg::initialize() {
ATH_CHECK(m_stripContainerKey.initialize());
ATH_CHECK(m_geoCtxKey.initialize());
ATH_CHECK(m_idHelperSvc.retrieve());
return StatusCode::SUCCESS;
}
......@@ -24,7 +22,11 @@ MuonStripCsvDumperAlg::MuonStripCsvDumperAlg(const std::string& name, ISvcLocato
StatusCode MuonStripCsvDumperAlg::execute(){
const EventContext& ctx{Gaudi::Hive::currentContext()};
const ActsGeometryContext gctx{};
SG::ReadHandle<ActsGeometryContext> gctxHandle{m_geoCtxKey, ctx};
ATH_CHECK(gctxHandle.isPresent());
const ActsGeometryContext& gctx{*gctxHandle};
const std::string delim = ",";
std::ofstream file{std::string(Form("event%09zu-",++m_event))+
m_preFix+"Strips.csv"};
......@@ -45,24 +47,10 @@ MuonStripCsvDumperAlg::MuonStripCsvDumperAlg(const std::string& name, ISvcLocato
ATH_CHECK(readHandle.isPresent());
for(const xAOD::UncalibratedMeasurement* strip : *readHandle){
Amg::Vector3D stripPos{Amg::Vector3D::Zero()};
const Identifier measId{(Identifier::value_type)strip->identifier()};
// const Amg::Transform toChambFrame
if (strip->type() == xAOD::UncalibMeasType::RpcStripType) {
const xAOD::RpcStrip* rpcStrip{static_cast<const xAOD::RpcStrip*>(strip)};
const IdentifierHash hash{rpcStrip->measurementHash()};
stripPos = rpcStrip->readoutElement()->getChamber()->globalToLocalTrans(gctx) *
rpcStrip->readoutElement()->stripPosition(gctx, hash);
} else if (strip->type() == xAOD::UncalibMeasType::TgcStripType) {
const xAOD::TgcStrip* tgcStrip{static_cast<const xAOD::TgcStrip*>(strip)};
const IdentifierHash hash{tgcStrip->measurementHash()};
stripPos = tgcStrip->readoutElement()->getChamber()->globalToLocalTrans(gctx) *
tgcStrip->readoutElement()->channelPosition(gctx, hash);
} else {
ATH_MSG_FATAL("Readout type "<<m_idHelperSvc->toString(measId)
<<" not implemented in "<<__FILE__);
return StatusCode::FAILURE;
}
const MuonR4::MuonSpacePoint spacePoint{gctx, strip};
const Amg::Vector3D& stripPos{spacePoint.positionInChamber()};
const Identifier& measId{spacePoint.identify()};
file<<strip->localPosition<1>().x()<<delim;
file<<strip->localCovariance<1>().x()<<delim;
......
......@@ -7,6 +7,7 @@
#include <AthenaBaseComps/AthAlgorithm.h>
#include <MuonIdHelpers/IMuonIdHelperSvc.h>
#include <StoreGate/ReadHandleKey.h>
#include <ActsGeometryInterfaces/ActsGeometryContext.h>
#include <xAODMeasurementBase/UncalibratedMeasurementContainer.h>
/** The MuonStripCsvDumperAlg reads the RpcStripContainer and dumps information to csv files
......@@ -24,6 +25,8 @@ class MuonStripCsvDumperAlg: public AthAlgorithm {
private:
SG::ReadHandleKey<ActsGeometryContext> m_geoCtxKey{this, "AlignmentKey", "ActsAlignment", "cond handle key"};
SG::ReadHandleKey<xAOD::UncalibratedMeasurementContainer> m_stripContainerKey{this, "ContainerKey",
"", "Key to the Rpc/Tgc container"};
......
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