20constexpr double TwoPi = 2 * std::numbers::pi;
21constexpr double PiOver2 = std::numbers::pi/2.;
26 std::vector<double>& he)
28 constexpr double PTTOCURVATURE = -0.301;
30 he[0] = 1. / std::tan(trkP->
theta());
31 he[1] = PTTOCURVATURE * trkP->
charge() / trkP->
pt();
33 if (trkP->
phi0() > 0.)
36 he[4] = TwoPi + trkP->
phi0();
38 double c1 = std::cos(trkP->
phi0());
39 double s1 = std::sin(trkP->
phi0());
40 he[3] = trkP->
d0() +
c1 * pvtx->
y() -
s1 * pvtx->
x();
44 he[2] = trkP->
z0() -
c1 * pvtx->
x() -
s1 * pvtx->
y() + pvtx->
z();
70 return StatusCode::SUCCESS;
100 for (
const auto* vertex : *vtxC) {
116 return StatusCode::FAILURE;
119 ATH_MSG_DEBUG(
"No primary vertex found. Setting default values.");
122 dh.
dphiv(*iele) = -1;
126 dh.
dambi(*iele) = -1;
131 return StatusCode::SUCCESS;
142 std::set<const xAOD::TrackParticle*> alreadyStored;
143 std::set<const xAOD::TrackParticle*> eleIDtpStored, eleGSFtpStored;
145 std::make_unique<ConstDataVector<xAOD::TrackParticleContainer>>(
148 for (
const auto* ele : *eleC) {
159 eleGSFtpStored.insert(eleGSFtp);
163 eleIDtpStored.insert(eleIDtp);
166 for (
const auto* tp : *idtpC) {
170 closeByTracks->push_back(tp);
171 alreadyStored.insert(tp);
176 if (alreadyStored.find(tp) != alreadyStored.end())
184 double dR = eleIDtp->
p4().DeltaR(tp->p4());
185 double dz = std::abs(eleIDtp->
z0() - tp->z0()) * std::sin(eleIDtp->
theta());
186 if (dR >= 0.3 || dz >=
m_dzCut)
193 alreadyStored.insert(tp);
195 closeByTracks->push_back(tp);
199 if (closeByTracks->empty())
200 return StatusCode::SUCCESS;
202 if (msgLvl(MSG::DEBUG)) {
208 << idtpC->
size() <<
" , number of selected close-by tracks "
209 << closeByTracks->size() <<
" , number of GSF tracks "
211 for (
const auto* trk : eleIDtpStored)
213 << trk <<
" pt = " << trk->pt() * 1e-3
214 <<
" eta = " << trk->eta() <<
" phi = " << trk->phi()
216 for (
const auto* trk : eleGSFtpStored)
218 << trk <<
" pt = " << trk->pt() * 1e-3
219 <<
" eta = " << trk->eta() <<
" phi = " << trk->phi()
223 << trk <<
" pt = " << trk->pt() * 1e-3
224 <<
" eta = " << trk->eta() <<
" phi = " << trk->phi()
228 for (
const auto* ele : *eleC) {
237 ATH_MSG_ERROR(
"Cannot decorate the electron with the simple info");
238 return StatusCode::FAILURE;
243 return StatusCode::SUCCESS;
268 <<
" phi = " << ele->
phi() <<
" GSF trk ptr = "
269 << eleGSFtrkP <<
" ID trk ptr " << eleIDtrkP);
274 double tpvr = -1, tpvp = 9e9, tpvz = 9e9;
276 truthEl->
prodVtx() !=
nullptr) {
281 dh.
dtrv(*ele) = tpvr;
282 dh.
dtpv(*ele) = tpvp;
283 dh.
dtzv(*ele) = tpvz;
289 double detaMin = 9e9;
292 if (tp->charge() * eletrkP->
charge() > 0)
296 double dR = eletrkP->
p4().DeltaR(tp->p4());
297 double dz = std::abs(eletrkP->
z0() - tp->z0()) * std::sin(eletrkP->
theta());
298 if (dR >= 0.3 || dz >=
m_dzCut)
301 double deta = std::abs(eletrkP->
eta() - tp->eta());
302 if (deta < detaMin) {
311 double meeAtVtx = -1.;
313 bool goodConv =
false;
326 mee = (ep4 + op4).M();
327 op4.SetPhi(eletrkP->
phi());
328 meeAtVtx = (ep4 + op4).M();
331 std::vector<double> helix1, helix2;
334 helix(eletrkP, pvtx, helix1);
335 helix(otrkP, pvtx, helix2);
338 if (helix1[4] < helix2[4])
339 beta = PiOver2 - helix1[4];
341 beta = PiOver2 - helix2[4];
343 double phi1(helix1[4] + beta);
349 double phi2(helix2[4] + beta);
356 double r1 = 1 / (2. * std::abs(helix1[1]));
361 double rcenter1(helix1[3] / charge1 + r1);
362 double phicenter1(phi1 + PiOver2 * charge1);
364 double x1 = rcenter1 * std::cos(phicenter1);
365 double y1 = rcenter1 * std::sin(phicenter1);
368 double r2 = 1 / (2. * std::abs(helix2[1]));
373 double rcenter2(helix2[3] / charge2 + r2);
374 double phicenter2(phi2 + PiOver2 * charge2);
376 double x2 = rcenter2 * std::cos(phicenter2);
377 double y2 = rcenter2 * std::sin(phicenter2);
381 if (std::abs(dx) < 1e-9) {
382 dx = std::copysign(1e-9, dx);
384 double slope((y1 - y2) / dx);
385 double b(y1 - slope * x1);
386 double alpha(std::atan(slope));
387 double d(std::sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));
389 double separation = d - r1 - r2;
392 cpx1 = x1 - r1 * std::cos(alpha);
393 cpx2 = x2 + r2 * std::cos(alpha);
395 cpx1 = x1 + r1 * std::cos(alpha);
396 cpx2 = x2 - r2 * std::cos(alpha);
399 double temp1 = (cpx1 + cpx2) / 2;
400 double temp2 = slope * temp1 + b;
401 double convX = std::cos(beta) * temp1 + std::sin(beta) * temp2;
402 double convY = -std::sin(beta) * temp1 + std::cos(beta) * temp2;
404 double dct(helix1[0] - helix2[0]);
410 pv = std::atan2(convY, convX);
411 rv = std::sqrt(convX * convX + convY * convY);
412 if (convX * std::cos(eletrkP->
phi()) + convY * std::sin(eletrkP->
phi()) < 0)
431 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
ATLAS-specific HepMC functions.
DataVector adapter that acts like it holds const pointers.
size_type size() const noexcept
Returns the number of elements in the collection.
Helper class to provide constant type-safe access to aux data.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
const_pointer_type ptr()
Dereference the pointer.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
virtual double phi() const override final
The azimuthal angle ( ) of the particle.
const xAOD::TrackParticle * trackParticle(size_t index=0) const
Pointer to the xAOD::TrackParticle/s that match the electron candidate.
float z0() const
Returns the parameter.
float theta() const
Returns the parameter, which has range 0 to .
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .).
float d0() const
Returns the parameter.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
float charge() const
Returns the charge.
float phi0() const
Returns the parameter, which has range to .
const TruthVertex_v1 * prodVtx() const
The production vertex of this particle.
float z() const
Vertex longitudinal distance along the beam line form the origin.
float phi() const
Vertex azimuthal angle.
float perp() const
Vertex transverse distance from the beam line.
float z() const
Returns the z position.
float y() const
Returns the y position.
float x() const
Returns the x position.
::StatusCode StatusCode
StatusCode definition for legacy code.
bool isElectron(const T &p)
constexpr double electronMassInMeV
the mass of the electron (in MeV)
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
const double he
same in ev
std::size_t numberOfSiHits(const xAOD::TrackParticle *tp)
return the number of Si hits in the track particle
const xAOD::TrackParticle * getOriginalTrackParticle(const xAOD::Electron *el)
Helper function for getting the "Original" Track Particle (i.e before GSF) via the electron.
const xAOD::TruthParticle * getTruthParticle(const xAOD::IParticle &p)
Return the truthParticle associated to the given IParticle (if any).
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
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.
TruthParticle_v1 TruthParticle
Typedef to implementation.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
Electron_v1 Electron
Definition of the current "egamma version".