ATLAS Offline Software
PTMaxReco.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3  */
4 
6 
7 #include "TopEvent/Event.h"
8 
9 namespace top {
10  PTMaxReco::PTMaxReco() : m_wmass(80400.), m_topmass(172500.) {
11  }
12 
14  }
15 
16  bool PTMaxReco::apply(const top::Event& event) const {
17  //get the hadronic top
18 
19  //jets that make-up the hadronic top quark
20  const xAOD::Jet* jet1 = nullptr;
21  const xAOD::Jet* jet2 = nullptr;
22  const xAOD::Jet* jet3 = nullptr;
23 
24  double maxptsq = 0.;
25 
26  for (xAOD::JetContainer::const_iterator j1 = event.m_jets.begin(); j1 != event.m_jets.end(); ++j1) {
27  for (xAOD::JetContainer::const_iterator j2 = j1 + 1; j2 != event.m_jets.end(); ++j2) {
28  for (xAOD::JetContainer::const_iterator j3 = j2 + 1; j3 != event.m_jets.end(); ++j3) {
29  const double px = (*j1)->px() + (*j2)->px() + (*j3)->px();
30  const double py = (*j1)->py() + (*j2)->py() + (*j3)->py();
31 
32  //pt2 to avoid the slow sqrt
33  const double ptsq = px * px + py * py;
34 
35  if (ptsq > maxptsq) {
36  jet1 = (*j1);
37  jet2 = (*j2);
38  jet3 = (*j3);
39  }
40  }
41  }
42  }
43 
44  //get the leptonic top
45 
46  //e+jets
47  TLorentzVector lepton;
48  if (event.m_electrons.size() == 1) lepton = event.m_electrons.at(0)->p4();
49 
50  //mu+jets
51  if (event.m_muons.size() == 1) lepton = event.m_muons.at(0)->p4();
52 
53  TLorentzVector nu = neutrinoCandidate(lepton, *event.m_met, true);
54 
55  const xAOD::Jet* lepb = nullptr;
56  double topdiff = 1000000.;
57  for (xAOD::JetContainer::const_iterator j1 = event.m_jets.begin(); j1 != event.m_jets.end(); ++j1) {
58  //ignore the three jets that make-up the hadronic top quark
59  if (*j1 == jet1 || *j1 == jet2 || *j1 == jet3) continue;
60 
61  //pick the jet which makes a leptonic top closest to the true top mass
62  const double tempdiff = fabs((lepton + nu + (*j1)->p4()).M());
63 
64  if ((tempdiff - m_topmass) < topdiff) {
65  lepb = *j1;
66  topdiff = tempdiff;
67  }
68  }
69 
70  if (lepb) std::cout << lepb->pt() << std::endl;
71 
72  return true;
73  }
74 
75  TLorentzVector PTMaxReco::neutrinoCandidate(const TLorentzVector& lep, const xAOD::MissingET& met,
76  bool dealWithNegative_nu) const {
77  const double px = met.mpx();
78  const double py = met.mpy();
79 
80  // solve quadratic to find neutrino four vector
81  double alpha = pow(m_wmass, 2) + pow((px + lep.Px()), 2) + pow((py + lep.Py()), 2) - pow(lep.E(), 2);
82  double beta = 0.5 * (alpha - pow(met.met(), 2) + pow(lep.Pz(), 2));
83  double gamma = -(beta * beta - (pow(lep.E(), 2) * pow(met.met(), 2))) / (pow(lep.E(), 2) - pow(lep.Pz(), 2));
84  double lambda = 2. * beta * lep.Pz() / (pow(lep.E(), 2) - pow(lep.Pz(), 2));
85  double delta = pow(lambda, 2) - 4 * gamma;
86 
87  if (delta < 0) { // ignore non real solutions
88  if (dealWithNegative_nu) delta = 0;
89  else return TLorentzVector();
90  }
91 
92  delta = sqrt(delta);
93 
94  double pz_pos = (lambda + delta) / 2.;
95  double pz_neg = (lambda - delta) / 2.;
96 
97  double pz = 0.0;
98 
99  if (fabs(pz_pos) > fabs(pz_neg)) pz = pz_neg;
100  else pz = pz_pos;
101 
102  double e = sqrt(px * px + py * py + pz * pz);
103 
104  TLorentzVector neutrino;
105  neutrino.SetPxPyPzE(px, py, pz, e);
106  return neutrino;
107  }
108 }
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
test_pyathena.px
px
Definition: test_pyathena.py:18
top
TopConfig A simple configuration that is NOT a singleton.
Definition: AnalysisTrackingHelper.cxx:58
top::PTMaxReco::neutrinoCandidate
TLorentzVector neutrinoCandidate(const TLorentzVector &lep, const xAOD::MissingET &met, bool dealWithNegative_nu) const
Definition: PTMaxReco.cxx:75
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
top::PTMaxReco::PTMaxReco
PTMaxReco()
Definition: PTMaxReco.cxx:10
top::PTMaxReco::apply
bool apply(const top::Event &) const override
This does stuff based on the information in an event.
Definition: PTMaxReco.cxx:16
top::PTMaxReco::m_topmass
double m_topmass
Definition: PTMaxReco.h:31
met
Definition: IMETSignificance.h:24
doubleTestComp.j1
j1
Definition: doubleTestComp.py:21
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
TrigVtx::gamma
@ gamma
Definition: TrigParticleTable.h:26
Amg::pz
@ pz
Definition: GeoPrimitives.h:40
xAOD::MissingET_v1
Principal data object for Missing ET.
Definition: MissingET_v1.h:25
Event.h
top::PTMaxReco::m_wmass
double m_wmass
Definition: PTMaxReco.h:30
Amg::py
@ py
Definition: GeoPrimitives.h:39
top::PTMaxReco::~PTMaxReco
virtual ~PTMaxReco()
Definition: PTMaxReco.cxx:13
PTMaxReco.h
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
xAOD::Jet_v1::p4
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition: Jet_v1.cxx:71
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
top::Event
Very simple class to hold event data after reading from a file.
Definition: Event.h:49
MuonParameters::beta
@ beta
Definition: MuonParamDefs.h:144
xAOD::Jet_v1::pt
virtual double pt() const
The transverse momentum ( ) of the particle.
Definition: Jet_v1.cxx:44
doubleTestComp.j2
j2
Definition: doubleTestComp.py:22