ATLAS Offline Software
Loading...
Searching...
No Matches
ElectronSiHitDecAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 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
15
16namespace CP
17{
19 {
25
32
33 ANA_CHECK (m_systematicsList.initialize());
34
35 ATH_MSG_INFO("Reading " << m_eventInfoKey.getNamePattern() << ", vertex " << m_vertexKey.getNamePattern() << ", and electrons " << m_electronContainerKey.getNamePattern() << " for decorating SiHit electrons.");
36
37 if (m_requireTwoLeptons) ATH_MSG_INFO("Requiring at least one pair of leptons from containers "
38 << m_analMuonContKey.getNamePattern() << " and "
39 << m_analElectronContKey.getNamePattern());
40 else ATH_MSG_INFO("No requirement on pairs of leptons. ");
41
42
43 // Return gracefully:
44 return StatusCode::SUCCESS;
45 }
46
47
48 StatusCode ElectronSiHitDecAlg::execute(const EventContext& ctx)
49 {
50
51 ATH_MSG_DEBUG("Entering execute");
52
53 // Loop over systematics
54 for (const auto& sys : m_systematicsList.systematicsVector()) {
55
56 // Check if event has at least one pair of muons or electrons
57 bool eventHasLeptonPair = false;
58
60 const xAOD::ElectronContainer* analEls = nullptr;
61 ANA_CHECK (m_analElectronContKey.retrieve (analEls, sys, ctx));
62 ATH_MSG_DEBUG("Retrieved electrons: " << analEls->size());
63 if (analEls->size() > 1) eventHasLeptonPair = true;
64 else {
65 const xAOD::MuonContainer* analMus = nullptr;
66 ANA_CHECK (m_analMuonContKey.retrieve (analMus, sys, ctx));
67 ATH_MSG_DEBUG("Retrieved muons: " << analMus->size());
68 if (analMus->size() > 1) eventHasLeptonPair = true;
69 }
70 }
71 else eventHasLeptonPair = true;
72 ATH_MSG_DEBUG("Event has lepton pair?: " << static_cast<int>(eventHasLeptonPair));
73
74
75 // Retrieve EventInfo
76 const xAOD::EventInfo* ei = nullptr;
77 ANA_CHECK (m_eventInfoKey.retrieve (ei, sys, ctx));
78 ATH_MSG_DEBUG("Retrieved EventInfo");
79
80 // Retrieve vertices
81 const xAOD::VertexContainer* vtxs = nullptr;
82 ANA_CHECK (m_vertexKey.retrieve (vtxs, sys, ctx));
83 ATH_MSG_DEBUG("Retrieved primary vertex");
84
85 // Retrieve electrons
86 const xAOD::ElectronContainer* els = nullptr;
87 ANA_CHECK (m_electronContainerKey.retrieve (els, sys, ctx));
88 ATH_MSG_DEBUG("Retrieved electrons: " << els->size());
89
90 // get primary vertex
91 const xAOD::Vertex* primaryVtx = nullptr;
92 for ( const auto *vtx : *vtxs) {
93 if (vtx->vertexType() == xAOD::VxType::PriVtx) {
94 primaryVtx = vtx;
95 break;
96 }
97 }
98
99 if (primaryVtx) {
100 ATH_MSG_DEBUG("Primary vtx z ntrk " << primaryVtx->z() << " "
101 << primaryVtx->nTrackParticles() << " index " << primaryVtx->index());
102 }
103
104 // Set the needed decorations for SiHit electrons
105 uint8_t val8;
106 for ( const auto *el : *els ) {
107
108 // Select or not SiHits depending on whether this event has an electron pair
109 char evtOK = (eventHasLeptonPair) ? 1 : 0;
110 m_evtOKDec.set(*el, evtOK, sys);
111 ATH_MSG_DEBUG( "SiHit el passes?: " << evtOK );
112
113 // Number of pixel hits in innermost or next to innermost pixel layer
114 int el_nInnerExpPix = -1;
115 int expInPix = el->trackParticleSummaryValue(val8, xAOD::expectInnermostPixelLayerHit)
116 ? val8 : -999;
117 int expNextInPix = el->trackParticleSummaryValue(val8, xAOD::expectNextToInnermostPixelLayerHit)
118 ? val8 : -999;
119 if (1 == expInPix) {
120 el_nInnerExpPix = el->trackParticleSummaryValue(val8, xAOD::numberOfInnermostPixelLayerHits)
121 ? val8 : -999;
122 }
123 else if (1 == expNextInPix) {
124 el_nInnerExpPix = el->trackParticleSummaryValue(val8, xAOD::numberOfNextToInnermostPixelLayerHits)
125 ? val8 : -999;
126 }
127 m_nInnerExpPix.set(*el, el_nInnerExpPix, sys);
128
129 // set z0stheta
130 const xAOD::TrackParticle* tp = el->trackParticle();
131 if (!tp) {
132 ATH_MSG_ERROR("SiHit electron has no track particle, cannot compute z0stheta and d0Normalized");
133 return StatusCode::FAILURE;
134 }
135 float z0stheta = 0;
136 if (primaryVtx) z0stheta = (tp->z0() - primaryVtx->z() + tp->vz()) * std::sin(tp->theta());
137 m_z0stheta.set(*el, z0stheta, sys);
138
139 // Set d0 normalized
140 float d0Normalized = std::abs(xAOD::TrackingHelpers::d0significance(tp, ei->beamPosSigmaX(), ei->beamPosSigmaY(), ei->beamPosSigmaXY()));
141 m_d0Normalized.set(*el, d0Normalized, sys);
142
143 // cluster eta, phi
144 const xAOD::CaloCluster* cluster = el->caloCluster();
145 if (!cluster) {
146 ATH_MSG_ERROR("SiHit electron has no calo cluster, cannot compute clEta and clPhi");
147 return StatusCode::FAILURE;
148 }
149 float clEta = cluster->eta();
150 float clPhi = cluster->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}
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_INFO(x,...)
#define ANA_CHECK(EXP)
check whether the given expression was successful
StatusCode initialize() override
SysReadHandle< xAOD::ElectronContainer > m_electronContainerKey
SysReadHandle< xAOD::VertexContainer > m_vertexKey
CP::SysWriteDecorHandle< float > m_clEta
CP::SysWriteDecorHandle< float > m_z0stheta
Decorators for the extra information from clusters and tracks for SiHit electrons.
CP::SysWriteDecorHandle< int > m_nInnerExpPix
CP::SysWriteDecorHandle< float > m_d0Normalized
SysReadHandle< xAOD::ElectronContainer > m_analElectronContKey
CP::SysWriteDecorHandle< char > m_evtOKDec
Decorator for SiHit electron for event requirement on a pair of leptons.
CP::SysWriteDecorHandle< float > m_clPhi
Gaudi::Property< bool > m_requireTwoLeptons
SysReadHandle< xAOD::EventInfo > m_eventInfoKey
SysReadHandle< xAOD::MuonContainer > m_analMuonContKey
SysListHandle m_systematicsList
the systematics list we run
size_type size() const noexcept
Returns the number of elements in the collection.
virtual::StatusCode execute()
execute this algorithm
virtual double eta() const
The pseudorapidity ( ) of the particle.
virtual double phi() const
The azimuthal angle ( ) of the particle.
float beamPosSigmaY() const
The width of the beam spot in the Y direction.
float beamPosSigmaXY() const
The beam spot shape's X-Y correlation.
float beamPosSigmaX() const
The width of the beam spot in the X direction.
float z0() const
Returns the parameter.
float theta() const
Returns the parameter, which has range 0 to .
float vz() const
The z origin for the parameters.
float z() const
Returns the z position.
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
Select isolated Photons, Electrons and Muons.
double d0significance(const xAOD::TrackParticle *tp, double d0_uncert_beam_spot_2)
@ PriVtx
Primary vertex.
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
EventInfo_v1 EventInfo
Definition of the latest event info version.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
@ expectInnermostPixelLayerHit
Do we expect a 0th-layer barrel hit for this track?
@ numberOfNextToInnermostPixelLayerHits
these are the hits in the 1st pixel barrel layer
@ expectNextToInnermostPixelLayerHit
Do we expect a 1st-layer barrel hit for this track?
@ numberOfInnermostPixelLayerHits
these are the hits in the 0th pixel barrel layer