ATLAS Offline Software
Loading...
Searching...
No Matches
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
17namespace 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
43 ANA_CHECK (m_systematicsList.initialize());
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 "
49 << m_analElectronContKey.getNamePattern());
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
70 const xAOD::ElectronContainer* analEls = nullptr;
71 ANA_CHECK (m_analElectronContKey.retrieve (analEls, sys));
72 ATH_MSG_DEBUG("Retrieved electrons: " << analEls->size());
73 if (analEls->size() > 1) eventHasLeptonPair = true;
74 else {
75 const xAOD::MuonContainer* analMus = nullptr;
76 ANA_CHECK (m_analMuonContKey.retrieve (analMus, sys));
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;
97 ANA_CHECK (m_electronContainerKey.retrieve (els, sys));
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 char evtOK = (eventHasLeptonPair) ? 1 : 0;
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(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
ElectronSiHitDecAlg(const std::string &name, ISvcLocator *pSvcLocator)
the standard constructor
SysReadHandle< xAOD::EventInfo > m_eventInfoKey
SysReadHandle< xAOD::MuonContainer > m_analMuonContKey
StatusCode execute() override
SysListHandle m_systematicsList
the systematics list we run
size_type size() const noexcept
Returns the number of elements in the collection.
AnaAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
size_t index() const
Return the index of this element within its container.
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 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.
This module defines the arguments passed from the BATCH driver to the BATCH worker.
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.
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