CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
Calculate Class Reference

Helper class for the calculation of a top and a W boson mass estime. More...

#include "DQM/Physics/interface/TopDQMHelpers.h"

Public Member Functions

 Calculate (int maxNJets, double wMass)
 default constructor More...
 
double massBTopQuark (const std::vector< reco::Jet > &jets, std::vector< double > VbtagWP, double btagWP_)
 calculate b-tagged t-quark mass estimate More...
 
double massTopQuark (const std::vector< reco::Jet > &jets)
 calculate t-quark mass estimate More...
 
double massWBoson (const std::vector< reco::Jet > &jets)
 calculate W boson mass estimate More...
 
double tmassTopQuark (reco::RecoCandidate *lep, const reco::MET &met, const reco::Jet &b)
 calculate top quark transverse mass estimate More...
 
double tmassWBoson (reco::RecoCandidate *lep, const reco::MET &met, const reco::Jet &b)
 calculate W boson transverse mass estimate More...
 
 ~Calculate ()
 default destructor More...
 

Private Member Functions

void operator() (const reco::Jet &bJet, reco::RecoCandidate *lepton, const reco::MET &met)
 do the calculation of the transverse top and W masses More...
 
void operator() (const std::vector< reco::Jet > &jets)
 
void operator2 (const std::vector< reco::Jet > &, std::vector< double >, double)
 do the calculation of the t-quark mass with one b-jet More...
 

Private Attributes

bool failed_
 indicate failed associations More...
 
double massBTopQuark_
 cache of b-tagged top quark mass estimate More...
 
double massTopQuark_
 cache of top quark mass estimate More...
 
double massWBoson_
 cache of w boson mass estimate More...
 
int maxNJets_
 max. number of jets to be considered More...
 
double tmassTopQuark_
 cache of top quark transverse mass estimate More...
 
double tmassWBoson_
 cache of W boson transverse mass estimate More...
 
double wMass_
 paramater of the w boson mass More...
 

Detailed Description

Helper class for the calculation of a top and a W boson mass estime.

Helper class for the calculation of a top and a W boson mass estimate. The core implementation originates from the plugin TtSemiLepHypMaxSumPtWMass in TopQuarkAnalysis/TopJetCombination package. It may be extended to include b tag information.

Definition at line 128 of file TopDQMHelpers.h.

Constructor & Destructor Documentation

◆ Calculate()

Calculate::Calculate ( int  maxNJets,
double  wMass 
)

default constructor

Definition at line 3 of file TopDQMHelpers.cc.

4  : failed_(false),
6  wMass_(wMass),
7  massWBoson_(-1.),
8  massTopQuark_(-1.),
9  massBTopQuark_(-1.),
10  tmassWBoson_(-1),
11  tmassTopQuark_(-1) {}

◆ ~Calculate()

Calculate::~Calculate ( )
inline

default destructor

Definition at line 133 of file TopDQMHelpers.h.

133 {};

Member Function Documentation

◆ massBTopQuark()

double Calculate::massBTopQuark ( const std::vector< reco::Jet > &  jets,
std::vector< double >  VbtagWP,
double  btagWP_ 
)

calculate b-tagged t-quark mass estimate

Definition at line 25 of file TopDQMHelpers.cc.

25  {
26  if (!failed_ && massBTopQuark_ < 0)
27  operator2(jets, VbtagWP, btagWP_);
28  return massBTopQuark_;
29 }

References failed_, singleTopDQM_cfi::jets, massBTopQuark_, and operator2().

Referenced by TopSingleLepton::MonitorEnsemble::fill().

◆ massTopQuark()

double Calculate::massTopQuark ( const std::vector< reco::Jet > &  jets)

calculate t-quark mass estimate

Definition at line 19 of file TopDQMHelpers.cc.

19  {
20  if (!failed_ && massTopQuark_ < 0)
22  return massTopQuark_;
23 }

References failed_, singleTopDQM_cfi::jets, massTopQuark_, and operator()().

Referenced by TopSingleLepton::MonitorEnsemble::fill(), and SingleTopTChannelLepton::MonitorEnsemble::fill().

◆ massWBoson()

double Calculate::massWBoson ( const std::vector< reco::Jet > &  jets)

calculate W boson mass estimate

Definition at line 13 of file TopDQMHelpers.cc.

13  {
14  if (!failed_ && massWBoson_ < 0)
16  return massWBoson_;
17 }

References failed_, singleTopDQM_cfi::jets, massWBoson_, and operator()().

Referenced by TopSingleLepton::MonitorEnsemble::fill(), and SingleTopTChannelLepton::MonitorEnsemble::fill().

◆ operator()() [1/2]

void Calculate::operator() ( const reco::Jet bJet,
reco::RecoCandidate lepton,
const reco::MET met 
)
private

do the calculation of the transverse top and W masses

Definition at line 43 of file TopDQMHelpers.cc.

43  {
44  double metT = sqrt(pow(met.px(), 2) + pow(met.py(), 2));
45  double lepT = sqrt(pow(lepton->px(), 2) + pow(lepton->py(), 2));
46  double bT = sqrt(pow(bJet.px(), 2) + pow(bJet.py(), 2));
47  reco::Particle::LorentzVector WT = lepton->p4() + met.p4();
48  tmassWBoson_ = sqrt(pow(metT + lepT, 2) - (WT.px() * WT.px()) - (WT.py() * WT.py()));
49  reco::Particle::LorentzVector topT = WT + bJet.p4();
50  tmassTopQuark_ = sqrt(pow((metT + lepT + bT), 2) - (topT.px() * topT.px()) - (topT.py() * topT.py()));
51 }

References BTaggingMonitor_cfi::met, reco::LeafCandidate::p4(), funct::pow(), reco::LeafCandidate::px(), reco::LeafCandidate::py(), mathSSE::sqrt(), tmassTopQuark_, and tmassWBoson_.

◆ operator()() [2/2]

void Calculate::operator() ( const std::vector< reco::Jet > &  jets)
private

do the calculation; this is called only once per event by the first function call to return a mass estimate. The once calculated values are cached afterwards

Definition at line 53 of file TopDQMHelpers.cc.

53  {
54  if (maxNJets_ < 0)
55  maxNJets_ = jets.size();
56  failed_ = jets.size() < (unsigned int)maxNJets_;
57  if (failed_) {
58  return;
59  }
60 
61  // associate those jets with maximum pt of the vectorial
62  // sum to the hadronic decay chain
63  double maxPt = -1.;
64  std::vector<int> maxPtIndices;
65  maxPtIndices.push_back(-1);
66  maxPtIndices.push_back(-1);
67  maxPtIndices.push_back(-1);
68 
69  for (int idx = 0; idx < maxNJets_; ++idx) {
70  for (int jdx = idx + 1; jdx < maxNJets_; ++jdx) {
71  //if (jdx <= idx) continue;
72  for (int kdx = 0; kdx < maxNJets_; ++kdx) {
73  if (kdx == idx || kdx == jdx)
74  continue;
75  reco::Particle::LorentzVector sum = jets[idx].p4() + jets[jdx].p4() + jets[kdx].p4();
76  if (maxPt < 0. || maxPt < sum.pt()) {
77  maxPt = sum.pt();
78  maxPtIndices.clear();
79  maxPtIndices.push_back(idx);
80  maxPtIndices.push_back(jdx);
81  maxPtIndices.push_back(kdx);
82  }
83  }
84  }
85  }
86  massTopQuark_ = (jets[maxPtIndices[0]].p4() + jets[maxPtIndices[1]].p4() + jets[maxPtIndices[2]].p4()).mass();
87 
88  // associate those jets that get closest to the W mass
89  // with their invariant mass to the W boson
90  double wDist = -1.;
91  std::vector<int> wMassIndices;
92  wMassIndices.push_back(-1);
93  wMassIndices.push_back(-1);
94  for (unsigned idx = 0; idx < maxPtIndices.size(); ++idx) {
95  for (unsigned jdx = 0; jdx < maxPtIndices.size(); ++jdx) {
96  if (jdx == idx || maxPtIndices[idx] > maxPtIndices[jdx])
97  continue;
98  reco::Particle::LorentzVector sum = jets[maxPtIndices[idx]].p4() + jets[maxPtIndices[jdx]].p4();
99  if (wDist < 0. || wDist > fabs(sum.mass() - wMass_)) {
100  wDist = fabs(sum.mass() - wMass_);
101  wMassIndices.clear();
102  wMassIndices.push_back(maxPtIndices[idx]);
103  wMassIndices.push_back(maxPtIndices[jdx]);
104  }
105  }
106  }
107  massWBoson_ = (jets[wMassIndices[0]].p4() + jets[wMassIndices[1]].p4()).mass();
108 }

References failed_, heavyIonCSV_trainingSettings::idx, createfilelist::int, singleTopDQM_cfi::jets, EgHLTOffHistBins_cfi::mass, massTopQuark_, massWBoson_, maxNJets_, L1TrackerEtMissProducer_cfi::maxPt, and wMass_.

Referenced by massTopQuark(), massWBoson(), tmassTopQuark(), and tmassWBoson().

◆ operator2()

void Calculate::operator2 ( const std::vector< reco::Jet > &  jets,
std::vector< double >  bjet,
double  btagWP 
)
private

do the calculation of the t-quark mass with one b-jet

Definition at line 110 of file TopDQMHelpers.cc.

110  {
111  if (maxNJets_ < 0)
112  maxNJets_ = jets.size();
113  failed_ = jets.size() < (unsigned int)maxNJets_;
114  if (failed_) {
115  return;
116  }
117  if (jets.size() != bjet.size()) {
118  return;
119  }
120 
121  // associate those jets with maximum pt of the vectorial
122  // sum to the hadronic decay chain. Require ONLY 1 btagged jet
123  double maxBPt = -1.;
124  std::vector<int> maxBPtIndices;
125  maxBPtIndices.push_back(-1);
126  maxBPtIndices.push_back(-1);
127  maxBPtIndices.push_back(-1);
128  for (int idx = 0; idx < maxNJets_; ++idx) {
129  for (int jdx = idx + 1; jdx < maxNJets_; ++jdx) {
130  //if (jdx <= idx) continue;
131  for (int kdx = 0; kdx < maxNJets_; ++kdx) {
132  if (kdx == idx || kdx == jdx)
133  continue;
134  // require only 1b-jet
135  if ((bjet[idx] > btagWP && bjet[jdx] <= btagWP && bjet[kdx] <= btagWP) ||
136  (bjet[idx] <= btagWP && bjet[jdx] > btagWP && bjet[kdx] <= btagWP) ||
137  (bjet[idx] <= btagWP && bjet[jdx] <= btagWP && bjet[kdx] > btagWP)) {
138  reco::Particle::LorentzVector sum = jets[idx].p4() + jets[jdx].p4() + jets[kdx].p4();
139  if (maxBPt < 0. || maxBPt < sum.pt()) {
140  maxBPt = sum.pt();
141  maxBPtIndices.clear();
142  maxBPtIndices.push_back(idx);
143  maxBPtIndices.push_back(jdx);
144  maxBPtIndices.push_back(kdx);
145  }
146  }
147  }
148  }
149  }
150  if (maxBPtIndices[0] < 0 || maxBPtIndices[1] < 0 || maxBPtIndices[2] < 0)
151  return;
152  massBTopQuark_ = (jets[maxBPtIndices[0]].p4() + jets[maxBPtIndices[1]].p4() + jets[maxBPtIndices[2]].p4()).mass();
153 }

References failed_, heavyIonCSV_trainingSettings::idx, createfilelist::int, singleTopDQM_cfi::jets, EgHLTOffHistBins_cfi::mass, massBTopQuark_, and maxNJets_.

Referenced by massBTopQuark().

◆ tmassTopQuark()

double Calculate::tmassTopQuark ( reco::RecoCandidate lep,
const reco::MET met,
const reco::Jet b 
)

calculate top quark transverse mass estimate

Definition at line 37 of file TopDQMHelpers.cc.

37  {
38  if (tmassTopQuark_ < 0)
39  operator()(b, lepton, met);
40  return tmassTopQuark_;
41 }

References b, BTaggingMonitor_cfi::met, operator()(), and tmassTopQuark_.

Referenced by SingleTopTChannelLepton::MonitorEnsemble::fill().

◆ tmassWBoson()

double Calculate::tmassWBoson ( reco::RecoCandidate lep,
const reco::MET met,
const reco::Jet b 
)

calculate W boson transverse mass estimate

Definition at line 31 of file TopDQMHelpers.cc.

31  {
32  if (tmassWBoson_ < 0)
33  operator()(b, mu, met);
34  return tmassWBoson_;
35 }

References b, BTaggingMonitor_cfi::met, amptDefaultParameters_cff::mu, operator()(), and tmassWBoson_.

Referenced by SingleTopTChannelLepton::MonitorEnsemble::fill().

Member Data Documentation

◆ failed_

bool Calculate::failed_
private

indicate failed associations

Definition at line 161 of file TopDQMHelpers.h.

Referenced by massBTopQuark(), massTopQuark(), massWBoson(), operator()(), and operator2().

◆ massBTopQuark_

double Calculate::massBTopQuark_
private

cache of b-tagged top quark mass estimate

Definition at line 171 of file TopDQMHelpers.h.

Referenced by massBTopQuark(), and operator2().

◆ massTopQuark_

double Calculate::massTopQuark_
private

cache of top quark mass estimate

Definition at line 169 of file TopDQMHelpers.h.

Referenced by massTopQuark(), and operator()().

◆ massWBoson_

double Calculate::massWBoson_
private

cache of w boson mass estimate

Definition at line 167 of file TopDQMHelpers.h.

Referenced by massWBoson(), and operator()().

◆ maxNJets_

int Calculate::maxNJets_
private

max. number of jets to be considered

Definition at line 163 of file TopDQMHelpers.h.

Referenced by operator()(), and operator2().

◆ tmassTopQuark_

double Calculate::tmassTopQuark_
private

cache of top quark transverse mass estimate

Definition at line 175 of file TopDQMHelpers.h.

Referenced by operator()(), and tmassTopQuark().

◆ tmassWBoson_

double Calculate::tmassWBoson_
private

cache of W boson transverse mass estimate

Definition at line 173 of file TopDQMHelpers.h.

Referenced by operator()(), and tmassWBoson().

◆ wMass_

double Calculate::wMass_
private

paramater of the w boson mass

Definition at line 165 of file TopDQMHelpers.h.

Referenced by operator()().

Calculate::massBTopQuark_
double massBTopQuark_
cache of b-tagged top quark mass estimate
Definition: TopDQMHelpers.h:171
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
L1TrackerEtMissProducer_cfi.maxPt
maxPt
Definition: L1TrackerEtMissProducer_cfi.py:14
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
Calculate::failed_
bool failed_
indicate failed associations
Definition: TopDQMHelpers.h:161
reco::Particle::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
BTaggingMonitor_cfi.met
met
Definition: BTaggingMonitor_cfi.py:84
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
reco::LeafCandidate::py
double py() const final
y coordinate of momentum vector
Definition: LeafCandidate.h:142
Calculate::operator()
void operator()(const std::vector< reco::Jet > &jets)
Definition: TopDQMHelpers.cc:53
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
Calculate::operator2
void operator2(const std::vector< reco::Jet > &, std::vector< double >, double)
do the calculation of the t-quark mass with one b-jet
Definition: TopDQMHelpers.cc:110
Calculate::massTopQuark_
double massTopQuark_
cache of top quark mass estimate
Definition: TopDQMHelpers.h:169
b
double b
Definition: hdecay.h:118
Calculate::maxNJets_
int maxNJets_
max. number of jets to be considered
Definition: TopDQMHelpers.h:163
createfilelist.int
int
Definition: createfilelist.py:10
reco::LeafCandidate::p4
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:114
SUSYDQMAnalyzer_cfi.maxNJets
maxNJets
Definition: SUSYDQMAnalyzer_cfi.py:13
Calculate::massWBoson_
double massWBoson_
cache of w boson mass estimate
Definition: TopDQMHelpers.h:167
Calculate::tmassWBoson_
double tmassWBoson_
cache of W boson transverse mass estimate
Definition: TopDQMHelpers.h:173
Calculate::tmassTopQuark_
double tmassTopQuark_
cache of top quark transverse mass estimate
Definition: TopDQMHelpers.h:175
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
pseudoTop_cfi.wMass
wMass
Definition: pseudoTop_cfi.py:12
Calculate::wMass_
double wMass_
paramater of the w boson mass
Definition: TopDQMHelpers.h:165
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
reco::LeafCandidate::px
double px() const final
x coordinate of momentum vector
Definition: LeafCandidate.h:140