ATLAS Offline Software
MuonMomentumBalanceSignificanceTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include "GaudiKernel/SystemOfUnits.h"
12 #include "TrkTrack/Track.h"
14 
15 using Gaudi::Units::GeV;
16 
17 namespace Rec {
18 
20  const IInterface* parent) :
22  declareInterface<IMuonMomentumBalanceSignificance>(this);
23  }
24 
26  // exclude statistical combination
27  if (muon.author() == xAOD::Muon::STACO) return 0.;
28 
29  // get combined track
30  const Trk::Track* theTrack =
31  muon.trackParticle(xAOD::Muon::CombinedTrackParticle) ? muon.trackParticle(xAOD::Muon::CombinedTrackParticle)->track() : nullptr;
32 
33  if (theTrack == nullptr) {
34  ATH_MSG_DEBUG("No primary author original track for refitted muon, stop calculation...");
35  return 0.0;
36  } else
37  return momentumBalanceSignificance(*theTrack);
38  }
39 
41  // find the TSOS carrying caloEnergy (TSOS type CaloDeposit)
42  // compare parameters with those from previous TSOS
43  double energyBalance = 0.;
44  const Trk::EnergyLoss* energyLoss = nullptr;
45  const Trk::TrackParameters* previousParameters = nullptr;
46  for (Trk::TrackStates::const_iterator s = track.trackStateOnSurfaces()->begin();
47  s != track.trackStateOnSurfaces()->end(); ++s) {
48  if (!(**s).trackParameters()) continue;
49  if ((**s).materialEffectsOnTrack()) {
50  const Trk::MaterialEffectsOnTrack* meot = dynamic_cast<const Trk::MaterialEffectsOnTrack*>((**s).materialEffectsOnTrack());
51  if (!meot) continue;
52  energyLoss = meot->energyLoss();
53  if ((**s).type(Trk::TrackStateOnSurface::CaloDeposit) && energyLoss && previousParameters) {
54  energyBalance = previousParameters->momentum().mag() - energyLoss->deltaE() - (**s).trackParameters()->momentum().mag();
55 
56  if (fabs(energyBalance) < energyLoss->sigmaDeltaE() || energyLoss->sigmaMinusDeltaE() <= 0.0 ||
57  energyLoss->sigmaPlusDeltaE() <= 0.0)
58 
59  {
60  ATH_MSG_VERBOSE(std::setiosflags(std::ios::fixed)
61  << " momentum balance " << std::setw(6) << std::setprecision(2) << energyBalance / GeV
62  << " significance " << std::setw(6) << std::setprecision(1)
63  << energyBalance / energyLoss->sigmaDeltaE() << " p before/after calo" << std::setw(7)
64  << std::setprecision(2) << previousParameters->momentum().mag() / GeV << " /" << std::setw(7)
65  << std::setprecision(2) << (**s).trackParameters()->momentum().mag() / GeV
66  << " energy deposit sigma " << energyLoss->sigmaDeltaE() / GeV << " GeV");
67  energyBalance /= energyLoss->sigmaDeltaE();
68  if (fabs(energyBalance) > 1.0)
69  ATH_MSG_DEBUG(" momentum balance using symmetric error "
70  << "as asymmetric error undefined ");
71  } else if (energyBalance < 0.) {
72  ATH_MSG_VERBOSE(std::setiosflags(std::ios::fixed)
73  << " momentum balance " << std::setw(6) << std::setprecision(2) << energyBalance / GeV
74  << " significance " << std::setw(6) << std::setprecision(1)
75  << energyBalance / energyLoss->sigmaDeltaE() << " p before/after calo" << std::setw(7)
76  << std::setprecision(2) << previousParameters->momentum().mag() / GeV << " /" << std::setw(7)
77  << std::setprecision(2) << (**s).trackParameters()->momentum().mag() / GeV
78  << " energy deposit sigma- " << energyLoss->sigmaMinusDeltaE() / GeV << " GeV");
79  energyBalance /= energyLoss->sigmaMinusDeltaE();
80  } else {
81  ATH_MSG_VERBOSE(std::setiosflags(std::ios::fixed)
82  << " momentum balance " << std::setw(6) << std::setprecision(2) << energyBalance / GeV
83  << " significance " << std::setw(6) << std::setprecision(1)
84  << energyBalance / energyLoss->sigmaDeltaE() << " p before/after calo" << std::setw(7)
85  << std::setprecision(2) << previousParameters->momentum().mag() / GeV << " /" << std::setw(7)
86  << std::setprecision(2) << (**s).trackParameters()->momentum().mag() / GeV
87  << " energy deposit sigma+ " << energyLoss->sigmaPlusDeltaE() / GeV << " GeV");
88  energyBalance /= energyLoss->sigmaPlusDeltaE();
89  }
90  break;
91  }
92  }
93 
94  // update previous parameters
95  previousParameters = (**s).trackParameters();
96  }
97 
98  return energyBalance;
99  }
100 
101 } // namespace Rec
Trk::EnergyLoss::sigmaMinusDeltaE
double sigmaMinusDeltaE() const
returns the negative side
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:195
Trk::TrackStateOnSurface::CaloDeposit
@ CaloDeposit
This TSOS contains a CaloEnergy object.
Definition: TrackStateOnSurface.h:135
EnergyLoss.h
ScatteringAngles.h
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
Rec::MuonMomentumBalanceSignificanceTool::MuonMomentumBalanceSignificanceTool
MuonMomentumBalanceSignificanceTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: MuonMomentumBalanceSignificanceTool.cxx:19
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
MeasurementBase.h
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
Trk::EnergyLoss::sigmaDeltaE
double sigmaDeltaE() const
returns the symmatric error
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
Track.h
MaterialEffectsOnTrack.h
Trk::MaterialEffectsOnTrack
represents the full description of deflection and e-loss of a track in material.
Definition: MaterialEffectsOnTrack.h:40
Rec
Name: MuonSpContainer.h Package : offline/Reconstruction/MuonIdentification/muonEvent.
Definition: FakeTrackBuilder.h:10
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
MuonMomentumBalanceSignificanceTool.h
Trk::EnergyLoss::deltaE
double deltaE() const
returns the
test_pyathena.parent
parent
Definition: test_pyathena.py:15
Trk::ParametersBase
Definition: ParametersBase.h:55
Rec::MuonMomentumBalanceSignificanceTool::momentumBalanceSignificance
double momentumBalanceSignificance(const xAOD::Muon &muon) const
Calculate momentum (im)balance significance of a muon (method will simply step down to the relevant t...
Definition: MuonMomentumBalanceSignificanceTool.cxx:25
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
Trk::EnergyLoss
This class describes energy loss material effects in the ATLAS tracking EDM.
Definition: EnergyLoss.h:34
Trk::ParametersBase::momentum
const Amg::Vector3D & momentum() const
Access method for the momentum.
Trk::MaterialEffectsOnTrack::energyLoss
const EnergyLoss * energyLoss() const
returns the energy loss object.
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
xAOD::STACO
@ STACO
Tracks produced by STACO.
Definition: TrackingPrimitives.h:99
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
AthAlgTool
Definition: AthAlgTool.h:26
Trk::EnergyLoss::sigmaPlusDeltaE
double sigmaPlusDeltaE() const
returns the positive side
TrackStateOnSurface.h