ATLAS Offline Software
SegmentFitParDecorAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
5 
7 #include "StoreGate/ReadHandle.h"
13 namespace MuonR4 {
14  using namespace SegmentFit;
17 
19  ATH_CHECK(m_idHelperSvc.retrieve());
20  ATH_CHECK(m_geoCtxKey.initialize());
21  ATH_CHECK(detStore()->retrieve(m_detMgr));
22  ATH_CHECK(m_segmentKey.initialize());
23  ATH_CHECK(m_locParKey.initialize());
24  ATH_CHECK(m_prdLinkKey.initialize());
25  ATH_CHECK(m_keyTgc.initialize(!m_keyTgc.empty()));
26  ATH_CHECK(m_keyRpc.initialize(!m_keyRpc.empty()));
27  ATH_CHECK(m_keyMdt.initialize(!m_keyMdt.empty()));
28  ATH_CHECK(m_keysTgc.initialize(!m_keysTgc.empty()));
29  ATH_CHECK(m_keyMM.initialize(!m_keyMM.empty()));
30  return StatusCode::SUCCESS;
31  }
33  const MeasKey_t& key,
34  const Identifier& measId,
35  const xAOD::UncalibratedMeasurement*& meas) const {
36  const PrdCont_t* cont{nullptr};
37  ATH_CHECK(SG::get(cont, key, ctx));
38  if (!cont) {
39  ATH_MSG_VERBOSE("No container key given");
40  return StatusCode::SUCCESS;
41  }
42  for (const xAOD::UncalibratedMeasurement* inCont : *cont) {
43  if (xAOD::identify(inCont) == measId) {
44  meas = inCont;
45  break;
46  }
47  }
48  if (!meas) {
49  ATH_MSG_WARNING("Failed to find the hit "<<m_idHelperSvc->toString(measId));
50  }
51  return StatusCode::SUCCESS;
52  }
53  StatusCode SegmentFitParDecorAlg::addLink(const EventContext& ctx,
54  const Identifier& rotId,
55  PrdLinkVec& prdLinks) const {
56  const xAOD::UncalibratedMeasurement* prd{nullptr};
57  switch(m_idHelperSvc->technologyIndex(rotId)){
58  case TechIdx_t::MDT:
59  ATH_CHECK(fetchMeasurement(ctx, m_keyMdt, rotId, prd));
60  break;
61  case TechIdx_t::RPC:
62  ATH_CHECK(fetchMeasurement(ctx, m_keyRpc, rotId, prd));
63  break;
64  case TechIdx_t::TGC:
65  ATH_CHECK(fetchMeasurement(ctx, m_keyTgc, rotId, prd));
66  break;
67  case TechIdx_t::MM:
68  ATH_CHECK(fetchMeasurement(ctx, m_keyMM, rotId, prd));
69  break;
70  case TechIdx_t::STGC:
71  ATH_CHECK(fetchMeasurement(ctx, m_keysTgc, rotId, prd));
72  break;
73  default:
74  break;
75  };
76  if (!prd) {
77  return StatusCode::SUCCESS;
78  }
79  ATH_MSG_VERBOSE("Link new measurement "<<m_idHelperSvc->toString(rotId));
80  PrdLink_t link{*static_cast<const PrdCont_t*>(prd->container()),
81  prd->index()};
82  prdLinks.push_back(std::move(link));
83  return StatusCode::SUCCESS;
84  }
85 
86 
87  StatusCode SegmentFitParDecorAlg::execute(const EventContext& ctx) const {
88  const xAOD::MuonSegmentContainer* segmentContainer{nullptr};
89  const ActsGeometryContext* gctx{nullptr};
90 
91  ATH_CHECK(SG::get(segmentContainer, m_segmentKey, ctx));
92  ATH_CHECK(SG::get(gctx, m_geoCtxKey, ctx));
93 
96  for (const xAOD::MuonSegment* seg : *segmentContainer) {
97  PrdLinkVec& prdLinks{prdLinkDecor(*seg)};
98  const Trk::Segment* trkSeg{*seg->muonSegment()};
99 
100  for (const Trk::MeasurementBase* meas : trkSeg->containedMeasurements()) {
101  const auto* rot = dynamic_cast<const Trk::RIO_OnTrack*>(meas);
102  if (rot) {
103  ATH_CHECK(addLink(ctx, rot->identify(), prdLinks));
104  continue;
105  }
106  const auto* cRot = dynamic_cast<const Trk::CompetingRIOsOnTrack*>(meas);
107  if (cRot) {
108  for (unsigned int r = 0 ; r < cRot->numberOfContainedROTs(); ++r){
109  ATH_CHECK(addLink(ctx, cRot->rioOnTrack(r).identify(), prdLinks));
110  }
111  }
112  }
113  const MuonGMR4::SpectrometerSector* chamber = m_detMgr->getSectorEnvelope(xAOD::identify(*prdLinks.front()));
114  const Amg::Transform3D globToLoc{chamber->globalToLocalTrans(*gctx)};
115 
116  SegPars& locPars{parDecor(*seg)};
117 
118  const Amg::Vector3D locDir = globToLoc.linear() * seg->direction();
119  const Amg::Vector3D locPos = globToLoc * seg->position();
120 
121  const double travDist = Amg::intersect<3>(locPos, locDir, Amg::Vector3D::UnitZ(), 0).value_or(0);
122  const Amg::Vector3D atCentre = locPos + travDist * locDir;
123 
124  locPars[toInt(ParamDefs::x0)] = atCentre[toInt(AxisDefs::phi)];
125  locPars[toInt(ParamDefs::y0)] = atCentre[toInt(AxisDefs::eta)];
126  locPars[toInt(ParamDefs::theta)] = locDir.theta();
127  locPars[toInt(ParamDefs::phi)] = locDir.phi();
128  ATH_MSG_VERBOSE("Segment "<<chamber->identString()<<" at chamber centre "<<Amg::toString(atCentre)
129  <<" + x *"<<Amg::toString(locDir));
130  }
131  return StatusCode::SUCCESS;
132  }
133 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
TGC
@ TGC
Definition: RegSelEnums.h:33
beamspotman.r
def r
Definition: beamspotman.py:676
xAOD::identify
const Identifier & identify(const UncalibratedMeasurement *meas)
Returns the associated identifier from the muon measurement.
Definition: MuonSpectrometer/MuonPhaseII/Event/xAOD/xAODMuonPrepData/Root/UtilFunctions.cxx:61
STGC
@ STGC
Definition: RegSelEnums.h:39
UtilFunctions.h
MuonGMR4::SpectrometerSector
A spectrometer sector forms the envelope of all chambers that are placed in the same MS sector & laye...
Definition: SpectrometerSector.h:41
CompetingRIOsOnTrack.h
calibdata.chamber
chamber
Definition: calibdata.py:32
SegmentFitParDecorAlg.h
xAOD::MuonSegment_v1
Class describing a MuonSegment.
Definition: MuonSegment_v1.h:33
MM
@ MM
Definition: RegSelEnums.h:38
Trk::RIO_OnTrack
Definition: RIO_OnTrack.h:70
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::ReadHandleKey< PrdCont_t >
SpectrometerSector.h
MuonR4::SegmentFit::ParamDefs::phi
@ phi
MuonR4::SegmentFitParDecorAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: SegmentFitParDecorAlg.cxx:87
MuonR4::SegmentFit::AxisDefs::phi
@ phi
DeMoGenerateWWW.addLink
def addLink(l)
When https is found in a character line, add a link in html If none, simply return the line unchanged...
Definition: DeMoGenerateWWW.py:68
xAOD::UncalibratedMeasurement_v1
Definition: UncalibratedMeasurement_v1.h:13
Amg::toString
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Definition: GeoPrimitivesToStringConverter.h:40
SG::get
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
Definition: ReadCondHandle.h:287
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MuonR4::SegPars
xAOD::MeasVector< toInt(ParamDefs::nPars)> SegPars
Definition: SegmentFitParDecorAlg.cxx:15
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
Trk::Segment
Definition: Tracking/TrkEvent/TrkSegment/TrkSegment/Segment.h:56
WriteDecorHandle.h
Handle class for adding a decoration to an object.
Trk::CompetingRIOsOnTrack
Base class for all CompetingRIOsOnTack implementations, extends the common MeasurementBase.
Definition: CompetingRIOsOnTrack.h:64
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MuonR4::SegmentFit::ParamDefs::x0
@ x0
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
MuonR4::SegmentFit::AxisDefs::eta
@ eta
ActsGeometryContext
Include the GeoPrimitives which need to be put first.
Definition: ActsGeometryContext.h:27
MuonR4::SegmentFitParDecorAlg::PrdLinkVec
std::vector< PrdLink_t > PrdLinkVec
Definition: SegmentFitParDecorAlg.h:29
xAOD::MeasVector
Eigen::Matrix< float, N, 1 > MeasVector
Abrivation of the Matrix & Covariance definitions.
Definition: MeasurementDefs.h:53
MuonR4::SegmentFitParDecorAlg::initialize
virtual StatusCode initialize() override final
Definition: SegmentFitParDecorAlg.cxx:18
Trk::MeasurementBase
Definition: MeasurementBase.h:58
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
MuonR4::SegmentFit::ParamDefs::y0
@ y0
RPC
@ RPC
Definition: RegSelEnums.h:32
MuonR4::SegmentFit::toInt
constexpr int toInt(const ParamDefs p)
Definition: MuonHoughDefs.h:42
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
python.copyTCTOutput.locDir
locDir
Definition: copyTCTOutput.py:113
MuonR4
This header ties the generic definitions in this package.
Definition: HoughEventData.h:16
SegmentFitterEventData.h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
MuonSegment.h
MuonR4::SegmentFitParDecorAlg::fetchMeasurement
StatusCode fetchMeasurement(const EventContext &ctx, const MeasKey_t &key, const Identifier &measId, const xAOD::UncalibratedMeasurement *&meas) const
Tries to load the PrdCont_t from StoreGate and then to find the uncalibrated measurement with the sam...
Definition: SegmentFitParDecorAlg.cxx:32
ReadHandle.h
Handle class for reading from StoreGate.
Muon::MuonStationIndex::TechnologyIndex
TechnologyIndex
enum to classify the different layers in the muon spectrometer
Definition: MuonStationIndex.h:54
MuonR4::SegmentFit::ParamDefs::nPars
@ nPars
MuonR4::SegmentFitParDecorAlg::addLink
StatusCode addLink(const EventContext &ctx, const Identifier &rotId, PrdLinkVec &prdLinks) const
Tries to add the Link to the uncalibrated measurement corresponding to the passed ROT id.
Definition: SegmentFitParDecorAlg.cxx:53
MuonR4::SegmentFit::ParamDefs::theta
@ theta
MDT
@ MDT
Definition: RegSelEnums.h:31
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
Identifier
Definition: IdentifierFieldParser.cxx:14