ATLAS Offline Software
Loading...
Searching...
No Matches
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
11namespace{
13 constexpr float dummy_val = -999.;
14}
15MuonTrkIDMSScatterDecorAlg::MuonTrkIDMSScatterDecorAlg(const std::string& name, ISvcLocator* pSvcLocator):
16 AthReentrantAlgorithm(name,pSvcLocator){}
17
19
20 ATH_CHECK(m_TrkContainer.initialize());
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
34 ATH_CHECK(m_deltaPhi1Key.initialize());
35 ATH_CHECK(m_deltaTheta1Key.initialize());
36 ATH_CHECK(m_sigmaDeltaPhi1Key.initialize());
37 ATH_CHECK(m_sigmaDeltaTheta1Key.initialize());
38
39 ATH_CHECK(m_deltaPhi0Key.initialize());
40 ATH_CHECK(m_deltaTheta0Key.initialize());
41 ATH_CHECK(m_sigmaDeltaPhi0Key.initialize());
42 ATH_CHECK(m_sigmaDeltaTheta0Key.initialize());
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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
Handle class for reading from StoreGate.
Handle class for adding a decoration to an object.
An algorithm that can be simultaneously executed in multiple threads.
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_TrkContainer
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_sigmaDeltaTheta0Key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_sigmaDeltaPhi0Key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_deltaTheta0Key
virtual StatusCode initialize() override
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_deltaPhi1Key
virtual StatusCode execute(const EventContext &ctx) const override
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_deltaPhi0Key
MuonTrkIDMSScatterDecorAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_sigmaDeltaTheta1Key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_sigmaDeltaPhi1Key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_deltaTheta1Key
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Handle class for adding a decoration to an object.
double deltaE() const
returns the
represents the full description of deflection and e-loss of a track in material.
const EnergyLoss * energyLoss() const
returns the energy loss object.
const ScatteringAngles * scatteringAngles() const
returns the MCS-angles object.
double sigmaDeltaPhi() const
returns the
double deltaPhi() const
returns the
double sigmaDeltaTheta() const
returns the
double deltaTheta() const
returns the
represents the track state (measurement, material, fit parameters and quality) at a surface.
TrackParticle_v1 TrackParticle
Reference the current persistent version: