ATLAS Offline Software
Loading...
Searching...
No Matches
SegmentRefitTest.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 "SegmentRefitTest.h"
5
9
15
16using namespace MuonR4::SegmentFit;
17using namespace Acts;
18
19namespace MuonValR4{
21 ATH_CHECK(m_preFitKey.initialize());
22 ATH_CHECK(m_postFitKey.initialize());
23 ATH_CHECK(m_linkKey.initialize());
24 ATH_CHECK(m_idHelperSvc.retrieve());
25
26 ATH_CHECK(m_tree.init(this));
27 return StatusCode::SUCCESS;
28 }
30 ATH_CHECK(m_tree.write());
31 return StatusCode::SUCCESS;
32 }
33
34 StatusCode SegmentRefitTest::execute(const EventContext& ctx) {
35 const xAOD::MuonSegmentContainer* postFitSegments{nullptr};
36 ATH_CHECK(SG::get(postFitSegments, m_postFitKey, ctx));
37
41 std::unordered_set<const xAOD::MuonSegment*> filledPreFits{};
42 auto fillPrefit = [&] (const xAOD::MuonSegment* seg) -> StatusCode {
43 if (!filledPreFits.insert(seg).second) {
44 return StatusCode::SUCCESS;
45 }
46
47 auto preFitPars = localSegmentPars(*seg);
48 m_chamberIndex = toUnderlying(seg->chamberIndex());
49 m_stationSide = seg->etaIndex();
50 m_stationPhi = seg->sector();
52 using enum ParamDefs;
53 m_preFitLocX = preFitPars[toUnderlying(x0)];
54 m_preFitLocY = preFitPars[toUnderlying(y0)];
55 m_preFitTheta = preFitPars[toUnderlying(theta)];
56 m_preFitPhi = preFitPars[toUnderlying(phi)];
58 auto cov = localSegmentCov(*seg);
59 if (cov) {
60 m_uncertLocX = Amg::error(*cov, toUnderlying(x0));
61 m_uncertLocY = Amg::error(*cov, toUnderlying(y0));
62 m_uncertTheta = Amg::error(*cov, toUnderlying(theta));
63 m_uncertPhi = Amg::error(*cov, toUnderlying(phi));
64 }
65
66 m_preFitChi2 = seg->chiSquared();
67 m_preFitNdoF = seg->numberDoF();
68 m_preFitNPrecHits = seg->nPrecisionHits();
69 m_preFitNTrigEtaHits = seg->nTrigEtaLayers();
70 m_preFitNTrigPhiHits = seg->nPhiLayers();
71 static const xAOD::PosAccessor<toUnderlying(nPars)> acc_seed{"seedSegPars"};
72 m_seedFitLocY = acc_seed(*seg)[toUnderlying(y0)];
73 m_seedFitTheta = acc_seed(*seg)[toUnderlying(theta)];
74 m_seedFitLocX = acc_seed(*seg)[toUnderlying(x0)];
75 m_seedFitPhi = acc_seed(*seg)[toUnderlying(phi)];
76
77 return m_tree.fill(ctx) ? StatusCode::SUCCESS : StatusCode::FAILURE;
78 };
80 for (const xAOD::MuonSegment* seg: *postFitSegments){
81 m_postFitChi2 = seg->chiSquared();
82 m_postFitNdoF = seg->numberDoF();
83 m_postFitNPrecHits = seg->nPrecisionHits();
84 m_postFitNTrigEtaHits = seg->nTrigEtaLayers();
85 m_postFitNTrigPhiHits = seg->nPhiLayers();
86 const auto segPars = localSegmentPars(*seg);
87 using enum ParamDefs;
88 m_postFitLocX = segPars[toUnderlying(x0)];
89 m_postFitLocY = segPars[toUnderlying(y0)];
90 m_postFitTheta = segPars[toUnderlying(theta)];
91 m_postFitPhi = segPars[toUnderlying(phi)];
92
93 m_goodFit = true;
94 ATH_CHECK(fillPrefit((*acc_segLink(*seg))));
95 }
96 const xAOD::MuonSegmentContainer* preFitSegments{nullptr};
97 ATH_CHECK(SG::get(preFitSegments, m_preFitKey, ctx));
98 for (const xAOD::MuonSegment* preFit: *preFitSegments) {
99 ATH_CHECK(fillPrefit(preFit));
100 }
101 ATH_MSG_DEBUG("Processing done");
102 return StatusCode::SUCCESS;
103 }
104}
Scalar phi() const
phi method
Scalar theta() const
theta method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
ElementLink< xAOD::TruthParticleContainer > Link_t
Handle class for reading a decoration on an object.
MuonVal::ScalarBranch< unsigned short > & m_preFitNPrecHits
Number of precision hits before the refit.
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_postFitKey
Declare the data dependency on the post fit segment container.
MuonVal::ScalarBranch< short > & m_stationSide
+1 for A-, -1 of C-side
MuonVal::ScalarBranch< float > & m_preFitLocY
Local Y before the refit.
MuonVal::ScalarBranch< float > & m_postFitLocY
Local Y after the refit.
MuonVal::MuonTesterTree m_tree
The output muon tester tree.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
IdHelperSvc to decode the Identifiers.
MuonVal::ScalarBranch< unsigned short > & m_preFitNTrigPhiHits
Number of phi trigger hits before the refit.
MuonVal::ScalarBranch< float > & m_uncertLocY
Uncertainty on the fitted local Y (prefit).
MuonVal::ScalarBranch< unsigned char > & m_goodFit
Flag whether the fit has succeeded or not.
MuonVal::ScalarBranch< unsigned short > & m_preFitNdoF
nDoF of the segment before the refit
MuonVal::ScalarBranch< float > & m_uncertTheta
Uncertainty on the fitted local Theta (prefit).
MuonVal::ScalarBranch< unsigned short > & m_postFitNTrigPhiHits
Number of phi trigger hits before the refit.
MuonVal::ScalarBranch< float > & m_preFitTheta
Local Theta before the refit.
MuonVal::ScalarBranch< float > & m_uncertPhi
Uncertainty on the fitted local Phi (prefit).
virtual StatusCode initialize() override final
MuonVal::ScalarBranch< int > & m_chamberIndex
chamber index field
MuonVal::ScalarBranch< float > & m_seedFitPhi
Local Phi after the refit.
MuonVal::ScalarBranch< float > & m_postFitLocX
Local X after the refit.
MuonVal::ScalarBranch< float > & m_seedFitTheta
Local Theta after the refit.
MuonVal::ScalarBranch< float > & m_postFitPhi
Local Phi after the refit.
MuonVal::ScalarBranch< unsigned short > & m_postFitNPrecHits
Number of precision hits after the refit.
MuonVal::ScalarBranch< float > & m_postFitChi2
Chi2 of the segment after the refit.
MuonVal::ScalarBranch< float > & m_uncertLocX
Uncertainty on the fitted local X (prefit).
MuonVal::ScalarBranch< float > & m_preFitLocX
Local X before the refit.
MuonVal::ScalarBranch< unsigned short > & m_postFitNdoF
nDoF of the segment after the refit
SG::ReadDecorHandleKey< xAOD::MuonSegmentContainer > m_linkKey
Construct a link from the refitted segment to the input segment.
MuonVal::ScalarBranch< unsigned short > & m_preFitNTrigEtaHits
Number of eta trigger hits before the refit.
MuonVal::ScalarBranch< float > & m_seedFitLocX
Local X after the refit.
MuonVal::ScalarBranch< float > & m_postFitTheta
Local Theta after the refit.
MuonVal::ScalarBranch< int > & m_stationPhi
phi index of the station
MuonVal::ScalarBranch< float > & m_seedFitLocY
Local Y after the refit.
virtual StatusCode finalize() override final
MuonVal::ScalarBranch< float > & m_preFitChi2
Chi2 of the segment before the refit.
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_preFitKey
Declare the data dependency on the standard Mdt+Rpc+Tgc segment container.
MuonVal::ScalarBranch< float > & m_preFitPhi
Local Phi before the refit.
virtual StatusCode execute(const EventContext &ctx) override final
Execute method.
MuonVal::ScalarBranch< unsigned short > & m_postFitNTrigEtaHits
Number of eta trigger hits before the refit.
Handle class for reading a decoration on an object.
double error(const Amg::MatrixX &mat, int index)
return diagonal error of the matrix caller should ensure the matrix is symmetric and the index is in ...
std::optional< Covariance > localSegmentCov(const xAOD::MuonSegment &seg)
Returns the localCovariance decoration from a xAOD::MuonSegment.
SeedingAux::FitParIndex ParamDefs
Use the same parameter indices as used by the CompSpacePointAuxiliaries.
Parameters localSegmentPars(const xAOD::MuonSegment &seg)
Returns the localSegPars decoration from a xAODMuon::Segment.
Lightweight algorithm to read xAOD MDT sim hits and (fast-digitised) drift circles from SG and fill a...
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
SG::AuxElement::Accessor< std::array< float, N > > PosAccessor
xAOD Accessor to the position
MuonSegmentContainer_v1 MuonSegmentContainer
Definition of the current "MuonSegment container version".
MuonSegment_v1 MuonSegment
Reference the current persistent version: