Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
AsgLeptonTrackDecorationAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
8 
9 #include <xAODEgamma/Electron.h>
10 #include <xAODMuon/Muon.h>
12 
13 
14 namespace CP
15 {
16 
18  initialize ()
19  {
20 
22 
25 
28 
30 
32  ANA_CHECK (m_primaryVerticesKey.initialize());
33 
34  return StatusCode::SUCCESS;
35  }
36 
38  execute (const EventContext &ctx) const
39  {
42  const xAOD::Vertex *primaryVertex {nullptr};
43 
44  for (const xAOD::Vertex *vertex : *vertices)
45  {
46  if (vertex->vertexType() == xAOD::VxType::PriVtx)
47  {
48  if (primaryVertex == nullptr)
49  {
50  primaryVertex = vertex;
51  break;
52  }
53  }
54  }
55 
56  for (const auto& sys : m_systematicsList.systematicsVector())
57  {
58  const xAOD::IParticleContainer *particles = nullptr;
60  for (const xAOD::IParticle *particle : *particles)
61  {
62  float d0sig = -999;
63  float d0 = -999;
64  float deltaZ0SinTheta = -999;
65  float deltaZ0SinThetasig = -999;
66 
67  const xAOD::TrackParticle *track {nullptr};
68  if (const xAOD::Muon *muon = dynamic_cast<const xAOD::Muon *>(particle)){
69  track = muon->primaryTrackParticle();
70  } else if (const xAOD::Electron *electron = dynamic_cast<const xAOD::Electron *>(particle)){
71  track = electron->trackParticle();
72  } else {
73  ANA_MSG_ERROR ("failed to cast input to electron or muon");
74  return StatusCode::FAILURE;
75  }
76 
77  if (track != nullptr) {
78  d0 = track->d0();
80  eventInfo->beamPosSigmaX(),
81  eventInfo->beamPosSigmaY(),
82  eventInfo->beamPosSigmaXY());
83 
84  const double vertex_z = primaryVertex ? primaryVertex->z() : 0;
85  deltaZ0SinTheta = (track->z0() + track->vz() - vertex_z) * sin (particle->p4().Theta());
86  deltaZ0SinThetasig = xAOD::TrackingHelpers::z0sinthetasignificance(track,primaryVertex);
87  }
88 
89  m_d0Handle.set(*particle,d0,sys);
90  m_d0sigHandle.set(*particle, d0sig, sys);
91  m_z0sinthetaHandle.set(*particle, deltaZ0SinTheta, sys);
92  m_z0sinthetasigHandle.set(*particle,deltaZ0SinThetasig,sys);
93  }
94  }
95 
96  return StatusCode::SUCCESS;
97  }
98 
99 } // namespace
CP::SysWriteDecorHandle::set
void set(const SG::AuxElement &object, const T &value, const CP::SystematicSet &sys) const
set the object decoration for the given systematic
CP::AsgLeptonTrackDecorationAlg::m_d0sigHandle
SysWriteDecorHandle< float > m_d0sigHandle
Definition: AsgLeptonTrackDecorationAlg.h:52
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:196
TrackParticlexAODHelpers.h
Muon.h
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
xAOD::TrackingHelpers::d0significance
double d0significance(const xAOD::TrackParticle *tp, double d0_uncert_beam_spot_2)
Definition: TrackParticlexAODHelpers.cxx:42
CP::AsgLeptonTrackDecorationAlg::initialize
StatusCode initialize() override
Definition: AsgLeptonTrackDecorationAlg.cxx:18
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
CP::SysListHandle::systematicsVector
const std::vector< CP::SystematicSet > & systematicsVector() const
the list of systematics to loop over
Definition: SysListHandle.cxx:96
CP::AsgLeptonTrackDecorationAlg::m_systematicsList
SysListHandle m_systematicsList
the systematics list we run
Definition: AsgLeptonTrackDecorationAlg.h:34
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:49
AsgLeptonTrackDecorationAlg.h
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
CP::AsgLeptonTrackDecorationAlg::m_z0sinthetaHandle
SysWriteDecorHandle< float > m_z0sinthetaHandle
Definition: AsgLeptonTrackDecorationAlg.h:55
xAOD::TrackingHelpers::z0sinthetasignificance
double z0sinthetasignificance(const xAOD::TrackParticle *tp, const xAOD::Vertex *vx=NULL)
Get the impact parameter significance of a track particle in the z direction, including the sin(theta...
Definition: TrackParticlexAODHelpers.cxx:82
CP::SysListHandle::initialize
::StatusCode initialize()
intialize this property
Definition: SysListHandle.cxx:69
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CP::SysWriteDecorHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize this handle
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition: TrackingPrimitives.h:572
TRT::Track::d0
@ d0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:62
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
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
CP::AsgLeptonTrackDecorationAlg::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
the EventInfo key
Definition: AsgLeptonTrackDecorationAlg.h:37
ReadHandle.h
Handle class for reading from StoreGate.
xAOD::Electron_v1
Definition: Electron_v1.h:34
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
CP::AsgLeptonTrackDecorationAlg::m_z0sinthetasigHandle
SysWriteDecorHandle< float > m_z0sinthetasigHandle
Definition: AsgLeptonTrackDecorationAlg.h:58
CP::AsgLeptonTrackDecorationAlg::m_d0Handle
SysWriteDecorHandle< float > m_d0Handle
Definition: AsgLeptonTrackDecorationAlg.h:49
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
CP::AsgLeptonTrackDecorationAlg::m_primaryVerticesKey
SG::ReadHandleKey< xAOD::VertexContainer > m_primaryVerticesKey
the PrimaryVertex key
Definition: AsgLeptonTrackDecorationAlg.h:41
Electron.h
xAOD::track
@ track
Definition: TrackingPrimitives.h:513
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
CP::AsgLeptonTrackDecorationAlg::execute
StatusCode execute(const EventContext &ctx) const override
Definition: AsgLeptonTrackDecorationAlg.cxx:38
CP::AsgLeptonTrackDecorationAlg::m_particlesHandle
SysReadHandle< xAOD::IParticleContainer > m_particlesHandle
the particle container we run on
Definition: AsgLeptonTrackDecorationAlg.h:46