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
35 const EventContext& ctx{Gaudi::Hive::currentContext()};
36 const xAOD::MuonSegmentContainer* postFitSegments{nullptr};
37 ATH_CHECK(SG::get(postFitSegments, m_postFitKey, ctx));
38
42 std::unordered_set<const xAOD::MuonSegment*> filledPreFits{};
43 auto fillPrefit = [&] (const xAOD::MuonSegment* seg) -> StatusCode {
44 if (!filledPreFits.insert(seg).second) {
45 return StatusCode::SUCCESS;
46 }
47 const MuonR4::Segment* reFitMe = MuonR4::detailedSegment(*seg);
48
49 auto preFitPars = localSegmentPars(*seg);
50 m_chamberIndex = toUnderlying(reFitMe->msSector()->chamberIndex());
51 m_stationSide = reFitMe->msSector()->side();
52 m_stationPhi = reFitMe->msSector()->stationPhi();
54 using enum ParamDefs;
55 m_preFitLocX = preFitPars[toUnderlying(x0)];
56 m_preFitLocY = preFitPars[toUnderlying(y0)];
57 m_preFitTheta = preFitPars[toUnderlying(theta)];
58 m_preFitPhi = preFitPars[toUnderlying(phi)];
60 m_uncertLocX = Amg::error(reFitMe->covariance(), toUnderlying(x0));
61 m_uncertLocY = Amg::error(reFitMe->covariance(), toUnderlying(y0));
62 m_uncertTheta = Amg::error(reFitMe->covariance(), toUnderlying(theta));
63 m_uncertPhi = Amg::error(reFitMe->covariance(), toUnderlying(phi));
64
65 m_preFitChi2 = reFitMe->chi2();
66 m_preFitNdoF = reFitMe->nDoF();
70 static const SG::ConstAccessor<xAOD::MeasVector<toUnderlying(nPars)>> acc_seed{"seedSegPars"};
71 m_seedFitLocY = acc_seed(*seg)[toUnderlying(y0)];
72 m_seedFitTheta = acc_seed(*seg)[toUnderlying(theta)];
73 m_seedFitLocX = acc_seed(*seg)[toUnderlying(x0)];
74 m_seedFitPhi = acc_seed(*seg)[toUnderlying(phi)];
75
76 return m_tree.fill(ctx) ? StatusCode::SUCCESS : StatusCode::FAILURE;
77 };
79 for (const xAOD::MuonSegment* seg: *postFitSegments){
80 m_postFitChi2 = seg->chiSquared();
81 m_postFitNdoF = seg->numberDoF();
82 m_postFitNPrecHits = seg->nPrecisionHits();
83 m_postFitNTrigEtaHits = seg->nTrigEtaLayers();
84 m_postFitNTrigPhiHits = seg->nPhiLayers();
85 const auto segPars = localSegmentPars(*seg);
86 using enum ParamDefs;
87 m_postFitLocX = segPars[toUnderlying(x0)];
88 m_postFitLocY = segPars[toUnderlying(y0)];
89 m_postFitTheta = segPars[toUnderlying(theta)];
90 m_postFitPhi = segPars[toUnderlying(phi)];
91
92 m_goodFit = true;
93 ATH_CHECK(fillPrefit((*acc_segLink(*seg))));
94 }
95 const xAOD::MuonSegmentContainer* preFitSegments{nullptr};
96 ATH_CHECK(SG::get(preFitSegments, m_preFitKey, ctx));
97 for (const xAOD::MuonSegment* preFit: *preFitSegments) {
98 ATH_CHECK(fillPrefit(preFit));
99 }
100 ATH_MSG_DEBUG("Processing done");
101 return StatusCode::SUCCESS;
102 }
103}
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)
Handle class for reading a decoration on an object.
int8_t side() const
Returns the side of the MS-sector 1 -> A side ; -1 -> C side.
int stationPhi() const
: Returns the station phi of the sector
Muon::MuonStationIndex::ChIndex chamberIndex() const
Returns the chamber index scheme.
Placeholder for what will later be the muon segment EDM representation.
unsigned int nDoF() const
Returns the number of degrees of freedom.
const SegmentFit::Covariance & covariance() const
Returns the uncertainties of the defining parameters.
const MuonGMR4::SpectrometerSector * msSector() const
Returns the associated MS sector.
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)
virtual StatusCode execute() override final
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.
MuonVal::ScalarBranch< unsigned short > & m_postFitNTrigEtaHits
Number of eta trigger hits before the refit.
Helper class to provide constant type-safe access to aux data.
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 ...
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.
const Segment * detailedSegment(const xAOD::MuonSegment &seg)
Helper function to navigate from the xAOD::MuonSegment to the MuonR4::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.
MuonSegmentContainer_v1 MuonSegmentContainer
Definition of the current "MuonSegment container version".
Eigen::Matrix< float, N, 1 > MeasVector
Abrivation of the Matrix & Covariance definitions.
MuonSegment_v1 MuonSegment
Reference the current persistent version: