ATLAS Offline Software
ElectronSiHitDecAlg.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 // ElectronSiHitDecAlg
7 //
8 // Add in decorations for a SiHit electron to include minimal information from
9 // track and cluster required for a minimal background estimation.
11 
16 
17 namespace CP
18 {
19  ElectronSiHitDecAlg::ElectronSiHitDecAlg(const std::string &name, ISvcLocator *svcLoc)
20  : EL::AnaAlgorithm(name, svcLoc)
21  {
22  }
23 
25  {
26  // Greet the user:
27  ATH_MSG_DEBUG("Initialising");
28 
29 
35 
42 
44 
45  ATH_MSG_INFO("Reading " << m_eventInfoKey.getNamePattern() << ", vertex " << m_vertexKey.getNamePattern() << ", and electrons " << m_electronContainerKey.getNamePattern() << " for decorating SiHit electrons.");
46 
47  if (m_requireTwoLeptons) ATH_MSG_INFO("Requiring at least one pair of leptons from containers "
48  << m_analMuonContKey.getNamePattern() << " and "
50  else ATH_MSG_INFO("No requirement on pairs of leptons. ");
51 
52 
53  // Return gracefully:
54  return StatusCode::SUCCESS;
55  }
56 
57 
59  {
60 
61  ATH_MSG_DEBUG("Entering execute");
62 
63  // Loop over systematics
64  for (const auto& sys : m_systematicsList.systematicsVector()) {
65 
66  // Check if event has at least one pair of muons or electrons
67  bool eventHasLeptonPair = false;
68 
69  if (m_requireTwoLeptons) {
70  const xAOD::ElectronContainer* analEls = nullptr;
72  ATH_MSG_DEBUG("Retrieved electrons: " << analEls->size());
73  if (analEls->size() > 1) eventHasLeptonPair = true;
74  else {
75  const xAOD::MuonContainer* analMus = nullptr;
77  ATH_MSG_DEBUG("Retrieved muons: " << analMus->size());
78  if (analMus->size() > 1) eventHasLeptonPair = true;
79  }
80  }
81  else eventHasLeptonPair = true;
82  ATH_MSG_DEBUG("Event has lepton pair?: " << (int)eventHasLeptonPair);
83 
84 
85  // Retrieve EventInfo
86  const xAOD::EventInfo* ei = nullptr;
87  ANA_CHECK (m_eventInfoKey.retrieve (ei, sys));
88  ATH_MSG_DEBUG("Retrieved EventInfo");
89 
90  // Retrieve vertices
91  const xAOD::VertexContainer* vtxs = nullptr;
92  ANA_CHECK (m_vertexKey.retrieve (vtxs, sys));
93  ATH_MSG_DEBUG("Retrieved primary vertex");
94 
95  // Retrieve electrons
96  const xAOD::ElectronContainer* els = nullptr;
98  ATH_MSG_DEBUG("Retrieved electrons: " << els->size());
99 
100  // get primary vertex
101  const xAOD::Vertex* primaryVtx = nullptr;
102  for ( auto vtx : *vtxs) {
103  if (vtx->vertexType() == xAOD::VxType::PriVtx) {
104  primaryVtx = vtx;
105  }
106  }
107 
108  if (primaryVtx) {
109  ATH_MSG_DEBUG("Primary vtx z ntrk " << primaryVtx->z() << " "
110  << primaryVtx->nTrackParticles() << " index " << primaryVtx->index());
111  }
112 
113  // Set the needed decorations for SiHit electrons
114  uint8_t val8;
115  for ( auto el : *els ) {
116 
117  // Select or not SiHits depending on whether this event has an electron pair
118  uint32_t evtOK = (eventHasLeptonPair) ? selectionAccept() : selectionReject();
119  m_evtOKDec.set(*el, evtOK, sys);
120  ATH_MSG_DEBUG( "SiHit el passes?: " << evtOK );
121 
122  // Number of pixel hits in innermost or next to innermost pixel layer
123  int el_nInnerExpPix = -1;
124  int expInPix = el->trackParticleSummaryValue(val8, xAOD::expectInnermostPixelLayerHit)
125  ? val8 : -999;
126  int expNextInPix = el->trackParticleSummaryValue(val8, xAOD::expectNextToInnermostPixelLayerHit)
127  ? val8 : -999;
128  if (1 == expInPix) {
129  el_nInnerExpPix = el->trackParticleSummaryValue(val8, xAOD::numberOfInnermostPixelLayerHits)
130  ? val8 : -999;
131  }
132  else if (1 == expNextInPix) {
133  el_nInnerExpPix = el->trackParticleSummaryValue(val8, xAOD::numberOfNextToInnermostPixelLayerHits)
134  ? val8 : -999;
135  }
136  m_nInnerExpPix.set(*el, el_nInnerExpPix, sys);
137 
138  // set z0stheta
139  auto tp = el->trackParticle();
140  float z0stheta = 0;
141  if (primaryVtx) z0stheta = (tp->z0() - primaryVtx->z() + tp->vz()) * sin(tp->theta());
142  m_z0stheta.set(*el, z0stheta, sys);
143 
144  // Set d0 normalized
145  float d0Normalized = std::abs(xAOD::TrackingHelpers::d0significance(tp, ei->beamPosSigmaX(), ei->beamPosSigmaY(), ei->beamPosSigmaXY()));
146  m_d0Normalized.set(*el, d0Normalized, sys);
147 
148  // cluster eta, phi
149  float clEta = el->caloCluster()->eta();
150  float clPhi = el->caloCluster()->phi();
151  m_clEta.set(*el, clEta, sys);
152  m_clPhi.set(*el, clPhi, sys);
153 
154 
155 
156  ATH_MSG_DEBUG("el pt,eta,ph " << el->pt()/1000. << ", " << el->eta() << ", " << el->phi());
157  ATH_MSG_DEBUG("Set z0stheta to " << z0stheta);
158  ATH_MSG_DEBUG("Set d0Norm to " << d0Normalized);
159  ATH_MSG_DEBUG("Set nInnerExpPix to " << el_nInnerExpPix);
160  ATH_MSG_DEBUG("Set cluster eta, phi to " << clEta << ", " << clPhi);
161  }
162  }
163 
164  ATH_MSG_DEBUG("Done !");
165 
166  return StatusCode::SUCCESS;
167  }
168 
169 }
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::ElectronSiHitDecAlg::m_vertexKey
SysReadHandle< xAOD::VertexContainer > m_vertexKey
Definition: ElectronSiHitDecAlg.h:46
xAOD::Vertex_v1::nTrackParticles
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
Definition: Vertex_v1.cxx:270
TrackParticlexAODHelpers.h
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
CP::ElectronSiHitDecAlg::initialize
StatusCode initialize() override
Definition: ElectronSiHitDecAlg.cxx:24
CP::ElectronSiHitDecAlg::execute
StatusCode execute() override
Definition: ElectronSiHitDecAlg.cxx:58
xAOD::TrackingHelpers::d0significance
double d0significance(const xAOD::TrackParticle *tp, double d0_uncert_beam_spot_2)
Definition: TrackParticlexAODHelpers.cxx:42
CP::ElectronSiHitDecAlg::m_analElectronContKey
SysReadHandle< xAOD::ElectronContainer > m_analElectronContKey
Definition: ElectronSiHitDecAlg.h:55
CP::ElectronSiHitDecAlg::m_clPhi
CP::SysWriteDecorHandle< float > m_clPhi
Definition: ElectronSiHitDecAlg.h:65
ParticleTest.tp
tp
Definition: ParticleTest.py:25
xAOD::EventInfo_v1::beamPosSigmaX
float beamPosSigmaX() const
The width of the beam spot in the X direction.
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
xAOD::expectInnermostPixelLayerHit
@ expectInnermostPixelLayerHit
Do we expect a 0th-layer barrel hit for this track?
Definition: TrackingPrimitives.h:236
CP::SysReadHandle::retrieve
::StatusCode retrieve(const T *&object, const CP::SystematicSet &sys) const
retrieve the object for the given name
CP::ElectronSiHitDecAlg::m_clEta
CP::SysWriteDecorHandle< float > m_clEta
Definition: ElectronSiHitDecAlg.h:64
CP::SysListHandle::systematicsVector
const std::vector< CP::SystematicSet > & systematicsVector() const
the list of systematics to loop over
Definition: SysListHandle.cxx:96
CP::ElectronSiHitDecAlg::ElectronSiHitDecAlg
ElectronSiHitDecAlg(const std::string &name, ISvcLocator *pSvcLocator)
the standard constructor
Definition: ElectronSiHitDecAlg.cxx:19
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
CP::ElectronSiHitDecAlg::m_requireTwoLeptons
Gaudi::Property< bool > m_requireTwoLeptons
Definition: ElectronSiHitDecAlg.h:58
CP::SysReadHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle)
initialize this handle
CP::ElectronSiHitDecAlg::m_d0Normalized
CP::SysWriteDecorHandle< float > m_d0Normalized
Definition: ElectronSiHitDecAlg.h:62
CP::ElectronSiHitDecAlg::m_evtOKDec
CP::SysWriteDecorHandle< uint32_t > m_evtOKDec
Decorator for SiHit electron for event requirement on a pair of leptons.
Definition: ElectronSiHitDecAlg.h:68
xAOD::expectNextToInnermostPixelLayerHit
@ expectNextToInnermostPixelLayerHit
Do we expect a 1st-layer barrel hit for this track?
Definition: TrackingPrimitives.h:247
CP::ElectronSiHitDecAlg::m_z0stheta
CP::SysWriteDecorHandle< float > m_z0stheta
Decorators for the extra information from clusters and tracks for SiHit electrons.
Definition: ElectronSiHitDecAlg.h:61
CP::SysListHandle::initialize
::StatusCode initialize()
intialize this property
Definition: SysListHandle.cxx:69
CP::ElectronSiHitDecAlg::m_analMuonContKey
SysReadHandle< xAOD::MuonContainer > m_analMuonContKey
Definition: ElectronSiHitDecAlg.h:52
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CP::ElectronSiHitDecAlg::m_electronContainerKey
SysReadHandle< xAOD::ElectronContainer > m_electronContainerKey
Definition: ElectronSiHitDecAlg.h:49
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
CP::SysWriteDecorHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize this handle
CP::ElectronSiHitDecAlg::m_systematicsList
SysListHandle m_systematicsList
the systematics list we run
Definition: ElectronSiHitDecAlg.h:40
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition: TrackingPrimitives.h:571
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition: AlgorithmWorkerData.h:24
CP::selectionReject
constexpr SelectionType selectionReject()
the selection decoration to apply for objects that are rejected
Definition: SelectionHelpers.h:44
CP::ElectronSiHitDecAlg::m_nInnerExpPix
CP::SysWriteDecorHandle< int > m_nInnerExpPix
Definition: ElectronSiHitDecAlg.h:63
xAOD::Vertex_v1::z
float z() const
Returns the z position.
SG::AuxElement::index
size_t index() const
Return the index of this element within its container.
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
xAOD::EventInfo_v1::beamPosSigmaY
float beamPosSigmaY() const
The width of the beam spot in the Y direction.
xAOD::numberOfNextToInnermostPixelLayerHits
@ numberOfNextToInnermostPixelLayerHits
these are the hits in the 1st pixel barrel layer
Definition: TrackingPrimitives.h:248
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
CP::ElectronSiHitDecAlg::m_eventInfoKey
SysReadHandle< xAOD::EventInfo > m_eventInfoKey
Definition: ElectronSiHitDecAlg.h:43
TrackParticle.h
ElectronSiHitDecAlg.h
xAOD::EventInfo_v1::beamPosSigmaXY
float beamPosSigmaXY() const
The beam spot shape's X-Y correlation.
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
CP::selectionAccept
constexpr SelectionType selectionAccept()
the selection decoration to apply for objects that are selected
Definition: SelectionHelpers.h:35
CP::SysReadHandle::getNamePattern
virtual std::string getNamePattern() const override
get the name pattern before substitution
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
xAOD::numberOfInnermostPixelLayerHits
@ numberOfInnermostPixelLayerHits
these are the hits in the 0th pixel barrel layer
Definition: TrackingPrimitives.h:237
SelectionHelpers.h