ATLAS Offline Software
MuonTrkIDMSScatterDecorAlg.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"
11 namespace{
13  constexpr float dummy_val = -999.;
14 }
15 MuonTrkIDMSScatterDecorAlg::MuonTrkIDMSScatterDecorAlg(const std::string& name, ISvcLocator* pSvcLocator):
16  AthReentrantAlgorithm(name,pSvcLocator){}
17 
19 
21 
22  m_deltaPhi1Key = m_TrkContainer.key() +".deltaphi_1";
23  m_deltaTheta1Key = m_TrkContainer.key() +".deltatheta_1";
24 
25  m_sigmaDeltaPhi1Key = m_TrkContainer.key() +".sigmadeltaphi_1";
26  m_sigmaDeltaTheta1Key = m_TrkContainer.key() +".sigmadeltatheta_1";
27 
28  m_deltaPhi0Key = m_TrkContainer.key() +".deltaphi_0";
29  m_deltaTheta0Key = m_TrkContainer.key() +".deltatheta_0";
30 
31  m_sigmaDeltaPhi0Key = m_TrkContainer.key() +".sigmadeltaphi_0";
32  m_sigmaDeltaTheta0Key = m_TrkContainer.key() +".sigmadeltatheta_0";
33 
38 
43  return StatusCode::SUCCESS;
44  }
45 
46  StatusCode MuonTrkIDMSScatterDecorAlg::execute(const EventContext& ctx) const {
48  if (!trkCont.isValid()) {
49  ATH_MSG_FATAL("Failed to load track collection "<<m_TrkContainer.fullKey());
50  return StatusCode::FAILURE;
51  }
52  Decorator dec_deltaphi_1{m_deltaPhi1Key,ctx};
53  Decorator dec_deltatheta_1{m_deltaTheta1Key, ctx};
54  Decorator dec_sigmadeltaphi_1{m_sigmaDeltaPhi1Key, ctx};
55  Decorator dec_sigmadeltatheta_1{m_sigmaDeltaTheta1Key, ctx};
56 
57  Decorator dec_deltaphi_0{m_deltaPhi0Key,ctx};
58  Decorator dec_deltatheta_0{m_deltaTheta0Key, ctx};
59  Decorator dec_sigmadeltaphi_0{m_sigmaDeltaPhi0Key, ctx};
60  Decorator dec_sigmadeltatheta_0{m_sigmaDeltaTheta0Key, ctx};
61 
62  for (const xAOD::TrackParticle* tp : *trkCont) {
63  dec_deltaphi_1(*tp) = dummy_val;
64  dec_deltatheta_1(*tp) = dummy_val;
65  dec_sigmadeltaphi_1(*tp) = dummy_val;
66  dec_sigmadeltatheta_1(*tp) = dummy_val;
67 
68  dec_deltaphi_0(*tp) = dummy_val;
69  dec_deltatheta_0(*tp) = dummy_val;
70  dec_sigmadeltaphi_0(*tp) = dummy_val;
71  dec_sigmadeltatheta_0(*tp) = dummy_val;
72  int nscatter = 0;
73  if (!tp->track() || !tp->track()->trackStateOnSurfaces()) continue;
74  for (const Trk::TrackStateOnSurface* tsos : *tp->track()->trackStateOnSurfaces()) {
75  if (tsos->materialEffectsOnTrack()) {
76  const Trk::MaterialEffectsOnTrack* meot = dynamic_cast<const Trk::MaterialEffectsOnTrack*>(tsos->materialEffectsOnTrack());
77  if (!meot->energyLoss() || !meot->scatteringAngles()) continue;
78  if (meot->energyLoss()->deltaE() == 0) { // artificial scatterer found
79  if (nscatter == 0) {
80  dec_deltaphi_0(*tp) = meot->scatteringAngles()->deltaPhi();
81  dec_deltatheta_0(*tp) = meot->scatteringAngles()->deltaTheta();
82  dec_sigmadeltaphi_0(*tp) = meot->scatteringAngles()->sigmaDeltaPhi();
83  dec_sigmadeltatheta_0(*tp) = meot->scatteringAngles()->sigmaDeltaTheta();
84  } else if (nscatter == 1) {
85  dec_deltaphi_1(*tp) = meot->scatteringAngles()->deltaPhi();
86  dec_deltatheta_1(*tp) = meot->scatteringAngles()->deltaTheta();
87  dec_sigmadeltaphi_1(*tp) = meot->scatteringAngles()->sigmaDeltaPhi();
88  dec_sigmadeltatheta_1(*tp) = meot->scatteringAngles()->sigmaDeltaTheta();
89  }
90  ++nscatter;
91  }
92  }
93  if (nscatter > 1) break;
94  }
95  }
96  return StatusCode::SUCCESS;
97 }
98 
Trk::ScatteringAngles::deltaPhi
double deltaPhi() const
returns the
Definition: ScatteringAngles.h:82
EnergyLoss.h
ScatteringAngles.h
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
MuonTrkIDMSScatterDecorAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: MuonTrkIDMSScatterDecorAlg.cxx:46
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
ParticleTest.tp
tp
Definition: ParticleTest.py:25
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
MuonTrkIDMSScatterDecorAlg.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
MuonTrkIDMSScatterDecorAlg::m_deltaTheta1Key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_deltaTheta1Key
Definition: MuonTrkIDMSScatterDecorAlg.h:30
MaterialEffectsOnTrack.h
Trk::MaterialEffectsOnTrack
represents the full description of deflection and e-loss of a track in material.
Definition: MaterialEffectsOnTrack.h:40
MuonTrkIDMSScatterDecorAlg::m_sigmaDeltaTheta1Key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_sigmaDeltaTheta1Key
Definition: MuonTrkIDMSScatterDecorAlg.h:33
Trk::ScatteringAngles::sigmaDeltaTheta
double sigmaDeltaTheta() const
returns the
Definition: ScatteringAngles.h:100
MuonTrkIDMSScatterDecorAlg::m_deltaPhi0Key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_deltaPhi0Key
Definition: MuonTrkIDMSScatterDecorAlg.h:35
MuonTrkIDMSScatterDecorAlg::m_deltaTheta0Key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_deltaTheta0Key
Definition: MuonTrkIDMSScatterDecorAlg.h:36
MuonTrkIDMSScatterDecorAlg::initialize
virtual StatusCode initialize() override
Definition: MuonTrkIDMSScatterDecorAlg.cxx:18
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MuonTrkIDMSScatterDecorAlg::m_TrkContainer
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_TrkContainer
Definition: MuonTrkIDMSScatterDecorAlg.h:27
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.
Trk::EnergyLoss::deltaE
double deltaE() const
returns the
MuonTrkIDMSScatterDecorAlg::m_deltaPhi1Key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_deltaPhi1Key
Definition: MuonTrkIDMSScatterDecorAlg.h:29
MuonTrkIDMSScatterDecorAlg::m_sigmaDeltaPhi1Key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_sigmaDeltaPhi1Key
Definition: MuonTrkIDMSScatterDecorAlg.h:32
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
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:221
MuonTrkIDMSScatterDecorAlg::m_sigmaDeltaPhi0Key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_sigmaDeltaPhi0Key
Definition: MuonTrkIDMSScatterDecorAlg.h:38
MuonTrkIDMSScatterDecorAlg::m_sigmaDeltaTheta0Key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_sigmaDeltaTheta0Key
Definition: MuonTrkIDMSScatterDecorAlg.h:39
Trk::MaterialEffectsOnTrack::energyLoss
const EnergyLoss * energyLoss() const
returns the energy loss object.
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.
Trk::MaterialEffectsOnTrack::scatteringAngles
const ScatteringAngles * scatteringAngles() const
returns the MCS-angles object.
Trk::ScatteringAngles::sigmaDeltaPhi
double sigmaDeltaPhi() const
returns the
Definition: ScatteringAngles.h:94
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
Trk::ScatteringAngles::deltaTheta
double deltaTheta() const
returns the
Definition: ScatteringAngles.h:88
ReadHandle.h
Handle class for reading from StoreGate.
MuonTrkIDMSScatterDecorAlg::MuonTrkIDMSScatterDecorAlg
MuonTrkIDMSScatterDecorAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: MuonTrkIDMSScatterDecorAlg.cxx:15