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

Merge branch 'HoughSpacePointAssoc' into 'main'

MuonHoughTransformTester - Dump optionally the space points and their association to the seeds

See merge request !78532
parents 61e15edc 6dfbad77
No related branches found
No related tags found
No related merge requests found
......@@ -38,12 +38,6 @@ atlas_add_test( HoughTransformTestR4
PRIVATE_WORKING_DIRECTORY
POST_EXEC_SCRIPT nopost.sh)
atlas_add_test( HoughTransformTestR4_withMM
SCRIPT python -m MuonPatternRecognitionTest.MuonHoughTransformTesterConfig --noMonitorPlots --nEvents 2 --noSTGC --noMdt --noRpc --noTgc --geoModelFile /cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/MuonRecRTT/ATLAS-R4-MUONTEST.db --condTag OFLCOND-MC21-SDR-RUN4-01 --geoTag ATLAS-P2-RUN4-01-00-00 --inputFile /cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/MuonGeomRTT/R4SimHits.pool.root
PROPERTIES TIMEOUT 600
PRIVATE_WORKING_DIRECTORY
POST_EXEC_SCRIPT nopost.sh)
atlas_add_test( FullChainIntegrationTest
SCRIPT python -m MuonPatternRecognitionTest.MuonRecoChainTesterConfig --nEvents 2 --noMM --noSTGC
PROPERTIES TIMEOUT 600
......
......@@ -6,14 +6,16 @@ if __name__=="__main__":
parser = SetupArgParser()
parser.add_argument("--noMonitorPlots", help="If set to true, there're no monitoring plots", default = False,
action='store_true')
parser.add_argument("--writeSpacePoints", help="If set to true, the spacepoints in the bucket are saved to disk",
default=False, action='store_true')
parser.set_defaults(nEvents = -1)
#parser.set_defaults(noMM=True)
#parser.set_defaults(noSTGC=True)
parser.set_defaults(noMM=True)
parser.set_defaults(noSTGC=True)
parser.set_defaults(outRootFile="HoughTransformTester.root")
#parser.set_defaults(condTag="CONDBR2-BLKPA-2023-03")
#parser.set_defaults(condTag="CONDBR2-BLKPA-2024-03")
parser.set_defaults(inputFile=[
#"/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/Tier0ChainTests/TCT_Run3/data22_13p6TeV.00431493.physics_Main.daq.RAW._lb0525._SFO-16._0001.data"
"/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/MuonGeomRTT/R3SimHits.pool.root"
......@@ -56,7 +58,7 @@ if __name__=="__main__":
cfg.merge(MuonHoughTransformTesterCfg(flags, SegmentSeedKey = "MuonHoughNswSegmentSeeds", SegmentKey = "R4NswSegments" ))
else:
cfg.merge(MuonSegmentFittingAlgCfg(flags))
cfg.merge(MuonHoughTransformTesterCfg(flags))
cfg.merge(MuonHoughTransformTesterCfg(flags, writeSpacePoints = args.writeSpacePoints))
if not args.noMonitorPlots and (flags.Detector.GeometryMDT or flags.Detector.GeometryRPC or flags.Detector.GeometryTGC):
cfg.getEventAlgo("MuonEtaHoughTransformAlg").VisualizationTool = cfg.popToolsAndMerge(PatternVisualizationToolCfg(flags,
......
/*
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
*/
#include "MuonHoughTransformTester.h"
......@@ -11,6 +11,7 @@
#include "xAODMuonPrepData/UtilFunctions.h"
#include "MuonPatternHelpers/HoughHelperFunctions.h"
#include "MuonTruthHelpers/MuonSimHitHelpers.h"
#include "Acts/Utilities/Enumerate.hpp"
#include "GaudiKernel/PhysicalConstants.h"
......@@ -31,9 +32,27 @@ namespace MuonValR4 {
ATH_CHECK(m_inHoughSegmentSeedKey.initialize());
ATH_CHECK(m_truthSegmentKey.initialize(!m_truthSegmentKey.empty()));
ATH_CHECK(m_inSegmentKey.initialize(!m_inSegmentKey.empty()));
ATH_CHECK(m_spKey.initialize(m_writeSpacePoints));
if (m_writeSpacePoints) {
m_spTester = std::make_unique<SpacePointTesterModule>(m_tree, m_spKey.key(), msgLevel());
m_tree.addBranch(m_spTester);
m_patternBucket = std::make_unique<MuonVal::VectorBranch<uint16_t>>(m_tree, "seedBucketId");
m_segmentBucket = std::make_unique<MuonVal::VectorBranch<uint16_t>>(m_tree, "segmentBucketId");
m_tree.addBranch(m_patternBucket);
m_tree.addBranch(m_segmentBucket);
m_spMatchedToPattern = std::make_unique<MuonVal::MatrixBranch<unsigned char>>(m_tree, "seedMatchedSp");
m_spMatchedToSegment = std::make_unique<MuonVal::MatrixBranch<unsigned char>>(m_tree, "segmentMatchedSp");
m_tree.addBranch(m_spMatchedToPattern);
m_tree.addBranch(m_spMatchedToSegment);
}
ATH_CHECK(m_tree.initialize(this));
ATH_CHECK(m_idHelperSvc.retrieve());
ATH_CHECK(detStore()->retrieve(m_r4DetMgr));
ATH_CHECK(m_visionTool.retrieve(EnableTool{!m_visionTool.empty()}));
ATH_MSG_DEBUG("Succesfully initialised");
return StatusCode::SUCCESS;
......@@ -232,9 +251,40 @@ namespace MuonValR4 {
m_tree.fillTruthInfo(obj.truthSegment, m_r4DetMgr, gctx);
m_tree.fillSeedInfo(obj);
m_tree.fillSegmentInfo(gctx, obj);
if (m_writeSpacePoints) {
for (const auto& [counter, max] : Acts::enumerate(obj.matchedSeeds)) {
m_patternBucket->get(counter) = m_spTester->push_back(*max->parentBucket());
std::vector<unsigned char> matched{};
matched.resize(max->parentBucket()->size());
for (const MuonR4::SpacePoint* sp : max->getHitsInMax()) {
unsigned treeIdx = m_spTester->push_back(*sp);
if (treeIdx >= matched.size()){
matched.resize(treeIdx +1);
}
matched[treeIdx] = true;
}
m_spMatchedToPattern->get(counter) = std::move(matched);
}
for (const auto& [counter, segment] : Acts::enumerate(obj.matchedSegments)) {
m_segmentBucket->get(counter) = m_spTester->push_back(*segment->parent()->parentBucket());
std::vector<unsigned char> matched{};
matched.resize(segment->parent()->parentBucket()->size());
for (const auto& meas : segment->measurements()) {
if (!meas->spacePoint()) {
continue;
}
unsigned treeIdx = m_spTester->push_back(*meas->spacePoint());
if (treeIdx >= matched.size()){
matched.resize(treeIdx +1);
}
matched[treeIdx] = true;
}
m_spMatchedToSegment->get(counter) = std::move(matched);
}
}
ATH_CHECK(m_tree.fill(ctx));
}
return StatusCode::SUCCESS;
}
} // namespace MuonValR4
......@@ -83,11 +83,26 @@ namespace MuonValR4{
SG::ReadHandleKey<MuonR4::SegmentSeedContainer> m_inHoughSegmentSeedKey{this, "SegmentSeedKey", "MuonHoughStationSegmentSeeds"};
SG::ReadHandleKey<MuonR4::SegmentContainer> m_inSegmentKey{this, "SegmentKey", "R4MuonSegments"};
SG::ReadHandleKey<MuonR4::SpacePointContainer> m_spKey{this, "SpacePointKey", "MuonSpacePoints"};
SG::ReadHandleKey<ActsGeometryContext> m_geoCtxKey{this, "AlignmentKey", "ActsAlignment", "cond handle key"};
ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc{this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
Gaudi::Property<bool> m_writeSpacePoints{this, "writeSpacePoints", false,
"Toggle whether the particular space poitns shall be written"};
/// @brief Branch dumping all the space points from the difference buckets
std::shared_ptr<SpacePointTesterModule> m_spTester{};
/// @brief Branch indicating to which bucket the i-th pattern is associated
std::shared_ptr<MuonVal::VectorBranch<uint16_t>> m_patternBucket{};
/// @brief Branch indicatin to which bucket the i-th segment is associated
std::shared_ptr<MuonVal::VectorBranch<uint16_t>> m_segmentBucket{};
/// @brief Branch indicating which space points in the tree are associated to the i-th pattern
std::shared_ptr<MuonVal::MatrixBranch<unsigned char>> m_spMatchedToPattern{};
/// @brief Branch indicating which space points in the tree are associated to the i-th segment
std::shared_ptr<MuonVal::MatrixBranch<unsigned char>> m_spMatchedToSegment{};
/// Pattern visualization tool
ToolHandle<MuonValR4::IPatternVisualizationTool> m_visionTool{this, "VisualizationTool", ""};
......
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