ATLAS Offline Software
MuonTrkAEOTDecorationAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include "StoreGate/ReadHandle.h"
8 
9  MuonTrkAEOTDecorationAlg::MuonTrkAEOTDecorationAlg(const std::string& name, ISvcLocator* pSvcLocator):
10  AthReentrantAlgorithm(name,pSvcLocator){}
11 
13 
15  ATH_CHECK(m_idHelperSvc.retrieve());
16  m_chIdKey = m_TrkContainer.key()+".alignEffectChId";
17  m_deltaTransKey = m_TrkContainer.key()+".alignEffectDeltaTrans";
18  m_sigmaDeltaTransKey = m_TrkContainer.key()+".alignEffectSigmaDeltaTrans";
19 
20  m_deltaAngleKey = m_TrkContainer.key()+".alignEffectDeltaAngle";
21  m_sigmaDeltaAngleKey = m_TrkContainer.key() +".alignEffectSigmaDeltaAngle";
25 
28 
29  return StatusCode::SUCCESS;
30  }
31 
32  StatusCode MuonTrkAEOTDecorationAlg::execute(const EventContext& ctx) const {
34  if (!trkCont.isValid()) {
35  ATH_MSG_FATAL("Failed to load track collection "<<m_TrkContainer.fullKey());
36  return StatusCode::FAILURE;
37  }
38 
44 
45  for (const xAOD::TrackParticle* tp : *trkCont) {
46 
47  std::vector<std::vector<unsigned int>>& chId = acc_ChId(*tp);
48  std::vector<float>& deltaTrans = acc_DeltaTrans(*tp);
49  std::vector<float>& sigmaDeltaTrans = acc_SigmaDeltaTrans(*tp);
50  std::vector<float>& deltaAngle = acc_deltaAngle(*tp);
51  std::vector<float>& sigmaDeltaAngle = acc_sigmaDeltaAngle(*tp);
52 
53  const Trk::Track* trk = tp->track();
54  if (!trk || !trk->trackStateOnSurfaces()){
55  ATH_MSG_DEBUG("Track has no TSOS?");
56  continue;
57  }
58  for (const Trk::TrackStateOnSurface* tsos : *trk->trackStateOnSurfaces()) {
59  if (!tsos->type(Trk::TrackStateOnSurface::Alignment)) continue;
60  const Trk::AlignmentEffectsOnTrack* aeot = tsos->alignmentEffectsOnTrack();
61  if (!aeot) continue;
62  std::set<unsigned int> chIdSet;
63  for (const Identifier& id : aeot->vectorOfAffectedTSOS()) {
64  if (!id.is_valid() || !m_idHelperSvc->isMuon(id)) continue;
65  chIdSet.insert(m_idHelperSvc->chamberIndex(id));
66  }
67  std::vector<unsigned int> chIdVec;
68  std::copy(chIdSet.begin(), chIdSet.end(), std::back_inserter(chIdVec));
69  chId.push_back(std::move(chIdVec));
70  deltaTrans.push_back(aeot->deltaTranslation());
71  sigmaDeltaTrans.push_back(aeot->sigmaDeltaTranslation());
72  deltaAngle.push_back(aeot->deltaAngle());
73  sigmaDeltaAngle.push_back(aeot->sigmaDeltaAngle());
74  }
75  }
76  return StatusCode::SUCCESS;
77  }
78 
MuonTrkAEOTDecorationAlg::initialize
virtual StatusCode initialize() override
Definition: MuonTrkAEOTDecorationAlg.cxx:12
MuonTrkAEOTDecorationAlg::m_TrkContainer
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_TrkContainer
Definition: MuonTrkAEOTDecorationAlg.h:29
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
MuonTrkAEOTDecorationAlg::m_deltaTransKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_deltaTransKey
Definition: MuonTrkAEOTDecorationAlg.h:33
Trk::Track::trackStateOnSurfaces
const Trk::TrackStates * trackStateOnSurfaces() const
return a pointer to a const DataVector of const TrackStateOnSurfaces.
Trk::AlignmentEffectsOnTrack::vectorOfAffectedTSOS
const std::vector< Identifier > & vectorOfAffectedTSOS() const
Returns a vector of the affected TSOS in the track.
Definition: AlignmentEffectsOnTrack.h:115
ParticleTest.tp
tp
Definition: ParticleTest.py:25
Trk::AlignmentEffectsOnTrack::deltaAngle
double deltaAngle() const
returns the
Definition: AlignmentEffectsOnTrack.h:103
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
MuonTrkAEOTDecorationAlg::MuonTrkAEOTDecorationAlg
MuonTrkAEOTDecorationAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: MuonTrkAEOTDecorationAlg.cxx:9
Trk::AlignmentEffectsOnTrack
Class to represent misalignments or 'discontinuities' on tracks These have a surface where the z axis...
Definition: AlignmentEffectsOnTrack.h:24
Trk::TrackStateOnSurface::Alignment
@ Alignment
This TSOS contains a Trk::AlignmentEffectsOnTrack.
Definition: TrackStateOnSurface.h:150
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
MuonTrkAEOTDecorationAlg.h
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
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
WriteDecorHandle.h
Handle class for adding a decoration to an object.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
MuonTrkAEOTDecorationAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: MuonTrkAEOTDecorationAlg.cxx:32
Trk::TrackStateOnSurface
represents the track state (measurement, material, fit parameters and quality) at a surface.
Definition: TrackStateOnSurface.h:71
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
MuonTrkAEOTDecorationAlg::m_chIdKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_chIdKey
Definition: MuonTrkAEOTDecorationAlg.h:32
SG::WriteDecorHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
MuonTrkAEOTDecorationAlg::m_deltaAngleKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_deltaAngleKey
Definition: MuonTrkAEOTDecorationAlg.h:36
Trk::AlignmentEffectsOnTrack::sigmaDeltaTranslation
double sigmaDeltaTranslation() const
returns the
Definition: AlignmentEffectsOnTrack.h:97
MuonTrkAEOTDecorationAlg::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: MuonTrkAEOTDecorationAlg.h:27
Trk::AlignmentEffectsOnTrack::deltaTranslation
double deltaTranslation() const
returns the
Definition: AlignmentEffectsOnTrack.h:91
calibdata.copy
bool copy
Definition: calibdata.py:27
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
ReadHandle.h
Handle class for reading from StoreGate.
Trk::AlignmentEffectsOnTrack::sigmaDeltaAngle
double sigmaDeltaAngle() const
returns the
Definition: AlignmentEffectsOnTrack.h:109
MuonTrkAEOTDecorationAlg::m_sigmaDeltaAngleKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_sigmaDeltaAngleKey
Definition: MuonTrkAEOTDecorationAlg.h:37
MuonTrkAEOTDecorationAlg::m_sigmaDeltaTransKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_sigmaDeltaTransKey
Definition: MuonTrkAEOTDecorationAlg.h:34
Identifier
Definition: IdentifierFieldParser.cxx:14