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
15
16namespace CP
17{
18 ElectronSiHitDecAlg::ElectronSiHitDecAlg(const std::string &name, ISvcLocator *svcLoc)
19 : EL::AnaAlgorithm(name, svcLoc)
20 {
21 }
22
24 {
25 // Greet the user:
26 ATH_MSG_DEBUG("Initialising");
27
28
34
41
42 ANA_CHECK (m_systematicsList.initialize());
43
44 ATH_MSG_INFO("Reading " << m_eventInfoKey.getNamePattern() << ", vertex " << m_vertexKey.getNamePattern() << ", and electrons " << m_electronContainerKey.getNamePattern() << " for decorating SiHit electrons.");
45
46 if (m_requireTwoLeptons) ATH_MSG_INFO("Requiring at least one pair of leptons from containers "
47 << m_analMuonContKey.getNamePattern() << " and "
48 << m_analElectronContKey.getNamePattern());
49 else ATH_MSG_INFO("No requirement on pairs of leptons. ");
50
51
52 // Return gracefully:
53 return StatusCode::SUCCESS;
54 }
55
56
58 {
59
60 ATH_MSG_DEBUG("Entering execute");
61
62 // Loop over systematics
63 for (const auto& sys : m_systematicsList.systematicsVector()) {
64
65 // Check if event has at least one pair of muons or electrons
66 bool eventHasLeptonPair = false;
67
69 const xAOD::ElectronContainer* analEls = nullptr;
70 ANA_CHECK (m_analElectronContKey.retrieve (analEls, sys));
71 ATH_MSG_DEBUG("Retrieved electrons: " << analEls->size());
72 if (analEls->size() > 1) eventHasLeptonPair = true;
73 else {
74 const xAOD::MuonContainer* analMus = nullptr;
75 ANA_CHECK (m_analMuonContKey.retrieve (analMus, sys));
76 ATH_MSG_DEBUG("Retrieved muons: " << analMus->size());
77 if (analMus->size() > 1) eventHasLeptonPair = true;
78 }
79 }
80 else eventHasLeptonPair = true;
81 ATH_MSG_DEBUG("Event has lepton pair?: " << (int)eventHasLeptonPair);
82
83
84 // Retrieve EventInfo
85 const xAOD::EventInfo* ei = nullptr;
86 ANA_CHECK (m_eventInfoKey.retrieve (ei, sys));
87 ATH_MSG_DEBUG("Retrieved EventInfo");
88
89 // Retrieve vertices
90 const xAOD::VertexContainer* vtxs = nullptr;
91 ANA_CHECK (m_vertexKey.retrieve (vtxs, sys));
92 ATH_MSG_DEBUG("Retrieved primary vertex");
93
94 // Retrieve electrons
95 const xAOD::ElectronContainer* els = nullptr;
96 ANA_CHECK (m_electronContainerKey.retrieve (els, sys));
97 ATH_MSG_DEBUG("Retrieved electrons: " << els->size());
98
99 // get primary vertex
100 const xAOD::Vertex* primaryVtx = nullptr;
101 for ( auto vtx : *vtxs) {
102 if (vtx->vertexType() == xAOD::VxType::PriVtx) {
103 primaryVtx = vtx;
104 }
105 }
106
107 if (primaryVtx) {
108 ATH_MSG_DEBUG("Primary vtx z ntrk " << primaryVtx->z() << " "
109 << primaryVtx->nTrackParticles() << " index " << primaryVtx->index());
110 }
111
112 // Set the needed decorations for SiHit electrons
113 uint8_t val8;
114 for ( auto el : *els ) {
115
116 // Select or not SiHits depending on whether this event has an electron pair
117 char evtOK = (eventHasLeptonPair) ? 1 : 0;
118 m_evtOKDec.set(*el, evtOK, sys);
119 ATH_MSG_DEBUG( "SiHit el passes?: " << evtOK );
120
121 // Number of pixel hits in innermost or next to innermost pixel layer
122 int el_nInnerExpPix = -1;
123 int expInPix = el->trackParticleSummaryValue(val8, xAOD::expectInnermostPixelLayerHit)
124 ? val8 : -999;
125 int expNextInPix = el->trackParticleSummaryValue(val8, xAOD::expectNextToInnermostPixelLayerHit)
126 ? val8 : -999;
127 if (1 == expInPix) {
128 el_nInnerExpPix = el->trackParticleSummaryValue(val8, xAOD::numberOfInnermostPixelLayerHits)
129 ? val8 : -999;
130 }
131 else if (1 == expNextInPix) {
132 el_nInnerExpPix = el->trackParticleSummaryValue(val8, xAOD::numberOfNextToInnermostPixelLayerHits)
133 ? val8 : -999;
134 }
135 m_nInnerExpPix.set(*el, el_nInnerExpPix, sys);
136
137 // set z0stheta
138 auto tp = el->trackParticle();
139 float z0stheta = 0;
140 if (primaryVtx) z0stheta = (tp->z0() - primaryVtx->z() + tp->vz()) * sin(tp->theta());
141 m_z0stheta.set(*el, z0stheta, sys);
142
143 // Set d0 normalized
144 float d0Normalized = std::abs(xAOD::TrackingHelpers::d0significance(tp, ei->beamPosSigmaX(), ei->beamPosSigmaY(), ei->beamPosSigmaXY()));
145 m_d0Normalized.set(*el, d0Normalized, sys);
146
147 // cluster eta, phi
148 float clEta = el->caloCluster()->eta();
149 float clPhi = el->caloCluster()->phi();
150 m_clEta.set(*el, clEta, sys);
151 m_clPhi.set(*el, clPhi, sys);
152
153
154
155 ATH_MSG_DEBUG("el pt,eta,ph " << el->pt()/1000. << ", " << el->eta() << ", " << el->phi());
156 ATH_MSG_DEBUG("Set z0stheta to " << z0stheta);
157 ATH_MSG_DEBUG("Set d0Norm to " << d0Normalized);
158 ATH_MSG_DEBUG("Set nInnerExpPix to " << el_nInnerExpPix);
159 ATH_MSG_DEBUG("Set cluster eta, phi to " << clEta << ", " << clPhi);
160 }
161 }
162
163 ATH_MSG_DEBUG("Done !");
164
165 return StatusCode::SUCCESS;
166 }
167
168}
#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
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