ATLAS Offline Software
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 
16 using namespace MuonR4::SegmentFit;
17 using namespace Acts;
18 
19 namespace 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();
67  m_preFitNPrecHits = reFitMe->summary().nPrecHits;
68  m_preFitNTrigEtaHits = reFitMe->summary().nEtaTrigHits;
69  m_preFitNTrigPhiHits = reFitMe->summary().nPhiHits;
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 }
MuonR4::Segment::summary
const HitSummary & summary() const
Returns the hit summary.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonPatternEvent/MuonPatternEvent/Segment.h:74
MuonR4::SegmentFit
Definition: MuonHoughDefs.h:34
MuonGMR4::SpectrometerSector::side
int8_t side() const
Returns the side of the MS-sector 1 -> A side ; -1 -> C side.
Definition: SpectrometerSector.cxx:57
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
MuonGMR4::SpectrometerSector::stationPhi
int stationPhi() const
: Returns the station phi of the sector
Definition: SpectrometerSector.cxx:63
EventPrimitivesHelpers.h
theta
Scalar theta() const
theta method
Definition: AmgMatrixBasePlugin.h:75
MuonR4::Segment
Placeholder for what will later be the muon segment EDM representation.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonPatternEvent/MuonPatternEvent/Segment.h:19
xAOD::MuonSegment_v1
Class describing a MuonSegment.
Definition: MuonSegment_v1.h:33
SegmentRefitTest.h
MuonR4::Segment::chi2
double chi2() const
Returns the chi2 of the segment fit.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonPatternEvent/MuonPatternEvent/Segment.h:45
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
MuonR4::SegmentFit::ParamDefs
SeedingAux::FitParIndex ParamDefs
Use the same parameter indices as used by the CompSpacePointAuxiliaries.
Definition: MuonHoughDefs.h:38
xAODUncalibMeasCalibrator.h
SpectrometerSector.h
MuonR4::Segment::nDoF
unsigned int nDoF() const
Returns the number of degrees of freedom.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonPatternEvent/MuonPatternEvent/Segment.h:47
MuonR4::Segment::HitSummary::nEtaTrigHits
unsigned nEtaTrigHits
Number of good Rpc / Tgc eta hits.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonPatternEvent/MuonPatternEvent/Segment.h:65
MuonR4::detailedSegment
const Segment * detailedSegment(const xAOD::MuonSegment &seg)
Helper function to navigate from the xAOD::MuonSegment to the MuonR4::Segment.
Definition: TrackingHelpers.cxx:22
MuonValR4::SegmentRefitTest::initialize
virtual StatusCode initialize() override final
Definition: SegmentRefitTest.cxx:20
MuonGMR4::SpectrometerSector::chamberIndex
Muon::MuonStationIndex::ChIndex chamberIndex() const
Returns the chamber index scheme.
Definition: SpectrometerSector.cxx:62
CalibrationContext.h
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition: StoreGate/StoreGate/ReadDecorHandle.h:94
Acts
Definition: MuonSpectrometer/MuonPhaseII/Event/xAOD/xAODMuonPrepData/xAODMuonPrepData/UtilFunctions.h:20
SG::get
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
Definition: ReadCondHandle.h:283
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MuonValR4::SegmentRefitTest::finalize
virtual StatusCode finalize() override final
Definition: SegmentRefitTest.cxx:29
MuonR4::Segment::msSector
const MuonGMR4::SpectrometerSector * msSector() const
Returns the associated MS sector.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonPatternEvent/MuonPatternEvent/Segment.h:39
DataVector
Derived DataVector<T>.
Definition: DataVector.h:795
MuonValR4
Lightweight algorithm to read xAOD MDT sim hits and (fast-digitised) drift circles from SG and fill a...
Definition: IPatternVisualizationTool.h:23
xAOD::MeasVector
Eigen::Matrix< float, N, 1 > MeasVector
Abrivation of the Matrix & Covariance definitions.
Definition: MeasurementDefs.h:53
MuonR4::Segment::HitSummary::nPrecHits
unsigned nPrecHits
Number of good Mdt / Mm / sTgc eta hits.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonPatternEvent/MuonPatternEvent/Segment.h:63
TrackingHelpers.h
Amg::error
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 ...
Definition: EventPrimitivesHelpers.h:40
SegmentFitterEventData.h
GeoPrimitivesToStringConverter.h
MuonR4::SegmentFit::localSegmentPars
Parameters localSegmentPars(const xAOD::MuonSegment &seg)
Returns the localSegPars decoration from a xAODMuon::Segment.
Definition: SegmentFitterEventData.cxx:42
ReadDecorHandle.h
Handle class for reading a decoration on an object.
MuonValR4::SegmentRefitTest::execute
virtual StatusCode execute() override final
Definition: SegmentRefitTest.cxx:34
MuonR4::Segment::HitSummary::nPhiHits
unsigned nPhiHits
Number of good Rpc / Tgc / sTgc phi hits.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonPatternEvent/MuonPatternEvent/Segment.h:67
MuonR4::Segment::covariance
const SegmentFit::Covariance & covariance() const
Returns the uncertainties of the defining parameters.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonPatternEvent/MuonPatternEvent/Segment.h:53