ATLAS Offline Software
Loading...
Searching...
No Matches
ElectronJetDRAssociator.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
13
14
21#include "xAODTracking/Vertex.h"
24#include <cmath>
25
26
27namespace D3PD {
28
29
37 const std::string& name,
38 const IInterface* parent)
39 : Base (type, name, parent),
40 m_target(0),
41 m_eg(0)
42{
43 declareProperty ("Target", m_targetLabel,
44 "Target label for the getter for the jets to which"
45 " to associate.");
46
47 declareProperty ("VertexContainerName",
48 m_vertexContainerName = "VxPrimaryCandidate",
49 "Primary vertex container name");
50
51 declareProperty ("DRCut", m_drcut = 0.7,
52 "DR cut between electrons and jets");
53
54 declareProperty ("CollectionGetterRegistry", m_registry,
55 "The ICollectionGetterRegistryTool instance.");
56
57 book().ignore(); // Avoid coverity warnings.
58}
59
60
65{
67 CHECK( Base::initialize() );
68 return StatusCode::SUCCESS;
69}
70
71
82 const std::type_info& ti)
83{
84 CHECK( m_registry.retrieve() );
85 CHECK( m_registry->get (m_targetLabel, this, m_target) );
87 return StatusCode::SUCCESS;
88}
89
90
96{
97 m_eg = &eg;
98 if (m_target)
99 CHECK( m_target->reset (true) );
100 return StatusCode::SUCCESS;
101}
102
103
110{
111 if (!m_target) return 0;
112
113 const xAOD::CaloCluster * clus= m_eg->caloCluster();
114 if (!clus){
115 ATH_MSG_WARNING("No cluster from the electron found!");
116 return 0;
117 }
118
119 while (const xAOD::Jet* myjet = m_target->next<xAOD::Jet>()) {
120
121 float dr = hypot (clus->p4().DeltaPhi(myjet->p4()),
122 myjet->eta() - clus->etaBE(2));
123 ATH_MSG_DEBUG("The value of DR between Electron and Jet is dr= "<<dr);
124 if (dr < m_drcut) {
125 float signedIP=-9999.9;
126 float PTRel=-9999.9;
127 float reducedPt=-9999.9;
128 ATH_MSG_DEBUG("CATA egamma pt clus " << clus->et() );
130 signedIP, PTRel ).isFailure() )
131 {
132 continue;
133 }
134 if ( findReducedPt ( m_eg, myjet, reducedPt ).isFailure() )
135 {
136 continue;
137 }
138
139 *m_signedIP = signedIP;
140 *m_ptrel = PTRel;
141 *m_dr = dr;
142 *m_jetSize = myjet->numConstituents();
143 *m_reducedPt = reducedPt;
144
145 return myjet;
146 }
147 }
148
149 return 0;
150}
151
152
159{
160 CHECK( addVariable( "dr" , m_dr,
161 "DR between electron and associated jet.") );
162 CHECK( addVariable( "signedIP" , m_signedIP,
163 "Signed impact parameter between electron and jet.") );
164 CHECK( addVariable( "ptrel", m_ptrel,
165 "Relative Pt between electron and jet.") );
166 CHECK( addVariable( "jetSize", m_jetSize,
167 "Number of jet constituents.") );
168 CHECK( addVariable( "reducedPt", m_reducedPt,
169 "Jet Pt with electron removed.") );
170 CHECK( Base::book() );
171 return StatusCode::SUCCESS;
172}
173
180StatusCode
182 const xAOD::Jet* j,
183 float& reducedPt )
184{
185 reducedPt=-9999.;
186
187 if ( !eg || !j )
188 return StatusCode::SUCCESS;
189
190 const xAOD::TrackParticle* track = eg->trackParticle();
191 if (!track) {
192 // Could legitimately be 0 for forward electrons...
193 return StatusCode::SUCCESS;
194 }
195
196 float px = j->px() - track->p4().Px();
197 float py = j->py() - track->p4().Py();
198 reducedPt = hypot (px, py);
199
200 return StatusCode::SUCCESS;
201}
202
203
210StatusCode
212 const xAOD::Jet* j0,
213 float& signedIP,
214 float& PTRel )
215{
216 signedIP=-9999;
217 PTRel =-9999;
218
219 if( j0==0 )
220 return StatusCode::SUCCESS;
221
222 const xAOD::TrackParticle* track = eg->trackParticle();
223 if (!track) {
224 // Could legitimately be 0 for forward electrons...
225 return StatusCode::SUCCESS;
226 }
227
228 PTRel= track->p4().Perp (j0->p4().Vect());
229
230 CLHEP::Hep3Vector jetDirection( (j0)->px(), (j0)->py(), (j0)->pz());
231 CLHEP::Hep3Vector unit = jetDirection.unit();
232
234 return StatusCode::SUCCESS;
235
236 const xAOD::Vertex* vx = 0;
237 {
238 const xAOD::VertexContainer * vxcontainer = nullptr;
239 if ( evtStore()->retrieve(vxcontainer, m_vertexContainerName).isFailure() )
240 REPORT_MESSAGE (MSG::WARNING)
241 << "Vertex container " << m_vertexContainerName
242 << " not found in StoreGate!";
243 else if (!vxcontainer->empty())
244 vx = vxcontainer->front();
245 }
246
247 if (!vx) {
248 REPORT_MESSAGE (MSG::WARNING)
249 << "No vertex found.";
250 return StatusCode::SUCCESS;
251 }
252
253 signedIP = m_trackToVertexIPEstimator->get2DLifetimeSignOfTrack
254 (track->perigeeParameters(), unit, *vx);
255
256 return StatusCode::SUCCESS;
257}
258
259
260} // namespace D3PD
261
262
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Helpers for checking error return status codes and reporting errors.
#define REPORT_MESSAGE(LVL)
Report a message.
#define CHECK(...)
Evaluate an expression and check for errors.
Abstract interface to keep a registry of collection getter tools.
Abstract interface to get a collection of objects and iterate over it.
virtual StatusCode addVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)
virtual StatusCode configureD3PD(IAddVariable *tree, const std::type_info &ti) override
Configure during initialization: type-check.
StatusCode findSignedIPAndPTRelEleJetPair(const xAOD::Electron *eg, const xAOD::Jet *j0, float &signedIP, float &PTRel)
Find the signed impact parameter and PTRel of EG's track relative to the beamspot.
float * m_ptrel
Variable: Relative Pt between electron and jet.
ToolHandle< ICollectionGetterRegistryTool > m_registry
Property: The ICollectionGetterRegistryTool instance.
ICollectionGetterTool * m_target
Getter defining the collection within which to index.
float * m_reducedPt
Variable: Jet pT with electron removed.
virtual StatusCode reset(const xAOD::Electron &eg) override
Start the iteration for a new association.
virtual StatusCode initialize() override
Standard Gaudi initialize method.
unsigned int * m_jetSize
Variable: Number of jet constituents.
double m_drcut
Property: DR cut between electrons and jets.
ToolHandle< Trk::ITrackToVertexIPEstimator > m_trackToVertexIPEstimator
Property: Tool for the estimation of the IPs to the vertex.
virtual StatusCode book() final
Create any needed tuple variables.
virtual const xAOD::Jet * next() override
Return a pointer to the next element in the association.
StatusCode findReducedPt(const xAOD::Electron *eg, const xAOD::Jet *j, float &reducedPt)
Find the pT of the jet with electron removed.
float * m_dr
Variable: DR between electron and jet.
float * m_signedIP
Variable: Signed impact parameter between electron and jet.
ElectronJetDRAssociator(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
MultiAssociationTool< xAOD::Electron, xAOD::Jet > Base
std::string m_vertexContainerName
Property: Vertex container name.
std::string m_targetLabel
Property: Target label for the getter for the jets to which to associate.
Common interface for adding a variable to a tuple.
virtual StatusCode configureD3PD(IAddVariable *tree, const std::type_info &ti)
const T * front() const
Access the first element in the collection as an rvalue.
bool empty() const noexcept
Returns true if the collection is empty.
virtual FourMom_t p4() const
The full 4-momentum of the particle.
float etaBE(const unsigned layer) const
Get the eta in one layer of the EM Calo.
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition Jet_v1.cxx:71
float py() const
The y-component of the jet's momentum.
Definition Jet_v1.cxx:94
float px() const
The x-component of the jet's momentum.
Definition Jet_v1.cxx:90
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:114
Block filler tool for noisy FEB information.
Jet_v1 Jet
Definition of the current "jet 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.
Electron_v1 Electron
Definition of the current "egamma version".
TChain * tree