253{
254
256
257
260
261
262
263 bool useGSF = false;
264
266
268 <<
" phi = " << ele->
phi() <<
" GSF trk ptr = "
269 << eleGSFtrkP << " ID trk ptr " << eleIDtrkP);
270
274 double tpvr = -1, tpvp = 9e9, tpvz = 9e9;
276 truthEl->
prodVtx() !=
nullptr) {
280 }
281 dh.dtrv(*ele) = tpvr;
282 dh.dtpv(*ele) = tpvp;
283 dh.dtzv(*ele) = tpvz;
284 }
285
286
287
289 double detaMin = 9e9;
291
292 if (tp->charge() * eletrkP->
charge() > 0)
293 continue;
294
295
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)
299 continue;
300
301 double deta = std::abs(eletrkP->
eta() - tp->eta());
302 if (deta < detaMin) {
303 otrkP = tp;
304 detaMin = deta;
305 }
306 }
307
310 double mee = -1.;
311 double meeAtVtx = -1.;
313 bool goodConv = false;
314
315 if (otrkP) {
316
317
318 TLorentzVector ep4;
320
321
322 TLorentzVector op4;
324
325
326 mee = (ep4 + op4).M();
327 op4.SetPhi(eletrkP->
phi());
328 meeAtVtx = (ep4 + op4).M();
329
330
331 std::vector<double> helix1, helix2;
332 helix1.resize(5);
333 helix2.resize(5);
334 helix(eletrkP, pvtx, helix1);
335 helix(otrkP, pvtx, helix2);
336
337 double beta(0.);
338 if (helix1[4] < helix2[4])
339 beta = PiOver2 - helix1[4];
340 else
341 beta = PiOver2 - helix2[4];
342
343 double phi1(helix1[4] + beta);
344 if (phi1 > TwoPi)
345 phi1 -= TwoPi;
346 if (phi1 < 0.)
347 phi1 += TwoPi;
348
349 double phi2(helix2[4] + beta);
350 if (phi2 > TwoPi)
351 phi2 -= TwoPi;
352 if (phi2 < 0.)
353 phi2 += TwoPi;
354
356 double r1 = 1 / (2. * std::abs(helix1[1]));
357
358 double charge1(1.);
359 if (helix1[1] < 0.)
360 charge1 = -1.;
361 double rcenter1(helix1[3] / charge1 + r1);
362 double phicenter1(phi1 + PiOver2 * charge1);
363
364 double x1 = rcenter1 * std::cos(phicenter1);
365 double y1 = rcenter1 * std::sin(phicenter1);
366
368 double r2 = 1 / (2. * std::abs(helix2[1]));
369
370 double charge2(1.);
371 if (helix2[1] < 0.)
372 charge2 = -1.;
373 double rcenter2(helix2[3] / charge2 + r2);
374 double phicenter2(phi2 + PiOver2 * charge2);
375
376 double x2 = rcenter2 * std::cos(phicenter2);
377 double y2 = rcenter2 * std::sin(phicenter2);
379
381 if (std::abs(dx) < 1e-9) {
382 dx = std::copysign(1e-9, dx);
383 }
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)));
388
389 double separation =
d -
r1 -
r2;
390 double cpx1, cpx2;
391 if (x1 > x2) {
392 cpx1 =
x1 -
r1 * std::cos(alpha);
393 cpx2 =
x2 +
r2 * std::cos(alpha);
394 } else {
395 cpx1 =
x1 +
r1 * std::cos(alpha);
396 cpx2 =
x2 -
r2 * std::cos(alpha);
397 }
398
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;
403
404 double dct(helix1[0] - helix2[0]);
405
408 goodConv = true;
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)
414 }
415 } else {
416 dh.dambi(*ele) = -1;
417 }
420 dh.dmee(*ele) = mee;
421 dh.dmeeVtx(*ele) = meeAtVtx;
424 dh.dambi(*ele) = 2;
425 else if (otrkP) {
427 dh.dambi(*ele) = 1;
428 else
429 dh.dambi(*ele) = 0;
430 }
431 return StatusCode::SUCCESS;
432}
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.
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .).
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.
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.
bool isElectron(const T &p)
constexpr double electronMassInMeV
the mass of the electron (in MeV)
const xAOD::TruthParticle * getTruthParticle(const xAOD::IParticle &p)
Return the truthParticle associated to the given IParticle (if any).
TruthParticle_v1 TruthParticle
Typedef to implementation.