CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 std::vector< reco::Jet > &jets)
 
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 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 68 of file TopDQMHelpers.h.

Constructor & Destructor Documentation

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) {}
double massWBoson_
cache of w boson mass estimate
double massTopQuark_
cache of top quark mass estimate
double tmassTopQuark_
cache of top quark transverse mass estimate
int maxNJets_
max. number of jets to be considered
double wMass_
paramater of the w boson mass
bool failed_
indicate failed associations
double tmassWBoson_
cache of W boson transverse mass estimate
double massBTopQuark_
cache of b-tagged top quark mass estimate
Calculate::~Calculate ( )
inline

default destructor

Definition at line 73 of file TopDQMHelpers.h.

73 {};

Member Function Documentation

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 23 of file TopDQMHelpers.cc.

References failed_, massBTopQuark_, and operator2().

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

24  {
25  if (!failed_ && massBTopQuark_ < 0) operator2(jets, VbtagWP, btagWP_);
26  return massBTopQuark_;
27 }
void operator2(const std::vector< reco::Jet > &, std::vector< double >, double)
do the calculation of the t-quark mass with one b-jet
vector< PseudoJet > jets
bool failed_
indicate failed associations
double massBTopQuark_
cache of b-tagged top quark mass estimate
double Calculate::massTopQuark ( const std::vector< reco::Jet > &  jets)

calculate t-quark mass estimate

Definition at line 18 of file TopDQMHelpers.cc.

References failed_, massTopQuark_, and operator()().

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

18  {
19  if (!failed_ && massTopQuark_ < 0) operator()(jets);
20  return massTopQuark_;
21 }
double massTopQuark_
cache of top quark mass estimate
vector< PseudoJet > jets
void operator()(const std::vector< reco::Jet > &jets)
bool failed_
indicate failed associations
double Calculate::massWBoson ( const std::vector< reco::Jet > &  jets)

calculate W boson mass estimate

Definition at line 13 of file TopDQMHelpers.cc.

References failed_, massWBoson_, and operator()().

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

13  {
14  if (!failed_ && massWBoson_ < 0) operator()(jets);
15  return massWBoson_;
16 }
double massWBoson_
cache of w boson mass estimate
vector< PseudoJet > jets
void operator()(const std::vector< reco::Jet > &jets)
bool failed_
indicate failed associations
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 54 of file TopDQMHelpers.cc.

References failed_, customizeTrackingMonitorSeedNumber::idx, massTopQuark_, massWBoson_, maxNJets_, and wMass_.

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

54  {
55  if (maxNJets_ < 0) 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 = 0; jdx < maxNJets_; ++jdx) {
71  if (jdx <= idx) continue;
72  for (int kdx = 0; kdx < maxNJets_; ++kdx) {
73  if (kdx == idx || kdx == jdx) continue;
75  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() +
87  jets[maxPtIndices[2]].p4()).mass();
88 
89  // associate those jets that get closest to the W mass
90  // with their invariant mass to the W boson
91  double wDist = -1.;
92  std::vector<int> wMassIndices;
93  wMassIndices.push_back(-1);
94  wMassIndices.push_back(-1);
95  for (unsigned idx = 0; idx < maxPtIndices.size(); ++idx) {
96  for (unsigned jdx = 0; jdx < maxPtIndices.size(); ++jdx) {
97  if (jdx == idx || maxPtIndices[idx] > maxPtIndices[jdx]) continue;
99  jets[maxPtIndices[idx]].p4() + jets[maxPtIndices[jdx]].p4();
100  if (wDist < 0. || wDist > fabs(sum.mass() - wMass_)) {
101  wDist = fabs(sum.mass() - wMass_);
102  wMassIndices.clear();
103  wMassIndices.push_back(maxPtIndices[idx]);
104  wMassIndices.push_back(maxPtIndices[jdx]);
105  }
106  }
107  }
108  massWBoson_ =
109  (jets[wMassIndices[0]].p4() + jets[wMassIndices[1]].p4()).mass();
110 }
double massWBoson_
cache of w boson mass estimate
double massTopQuark_
cache of top quark mass estimate
int maxNJets_
max. number of jets to be considered
vector< PseudoJet > jets
double wMass_
paramater of the w boson mass
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
bool failed_
indicate failed associations
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
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 41 of file TopDQMHelpers.cc.

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

42  {
43  double metT = sqrt(pow(met.px(), 2) + pow(met.py(), 2));
44  double lepT = sqrt(pow(lepton->px(), 2) + pow(lepton->py(), 2));
45  double bT = sqrt(pow(bJet.px(), 2) + pow(bJet.py(), 2));
46  reco::Particle::LorentzVector WT = lepton->p4() + met.p4();
47  tmassWBoson_ =
48  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()) -
51  (topT.py() * topT.py()));
52 }
double tmassTopQuark_
cache of top quark transverse mass estimate
T sqrt(T t)
Definition: SSEVec.h:48
virtual double px() const
x coordinate of momentum vector
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
virtual double py() const
y coordinate of momentum vector
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
double tmassWBoson_
cache of W boson transverse mass estimate
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 112 of file TopDQMHelpers.cc.

References failed_, customizeTrackingMonitorSeedNumber::idx, massBTopQuark_, and maxNJets_.

Referenced by massBTopQuark().

113  {
114  if (maxNJets_ < 0) maxNJets_ = jets.size();
115  failed_ = jets.size() < (unsigned int)maxNJets_;
116  if (failed_) {
117  return;
118  }
119  if (jets.size() != bjet.size()) {
120  return;
121  }
122 
123  // associate those jets with maximum pt of the vectorial
124  // sum to the hadronic decay chain. Require ONLY 1 btagged jet
125  double maxBPt = -1.;
126  std::vector<int> maxBPtIndices;
127  maxBPtIndices.push_back(-1);
128  maxBPtIndices.push_back(-1);
129  maxBPtIndices.push_back(-1);
130  for (int idx = 0; idx < maxNJets_; ++idx) {
131  for (int jdx = 0; jdx < maxNJets_; ++jdx) {
132  if (jdx <= idx) continue;
133  for (int kdx = 0; kdx < maxNJets_; ++kdx) {
134  if (kdx == idx || kdx == jdx) continue;
135  // require only 1b-jet
136  if ((bjet[idx] > btagWP && bjet[jdx] <= btagWP &&
137  bjet[kdx] <= btagWP) ||
138  (bjet[idx] <= btagWP && bjet[jdx] > btagWP &&
139  bjet[kdx] <= btagWP) ||
140  (bjet[idx] <= btagWP && bjet[jdx] <= btagWP &&
141  bjet[kdx] > btagWP)) {
143  jets[idx].p4() + jets[jdx].p4() + jets[kdx].p4();
144  if (maxBPt < 0. || maxBPt < sum.pt()) {
145  maxBPt = sum.pt();
146  maxBPtIndices.clear();
147  maxBPtIndices.push_back(idx);
148  maxBPtIndices.push_back(jdx);
149  maxBPtIndices.push_back(kdx);
150  }
151  }
152  }
153  }
154  }
155  if (maxBPtIndices[0] < 0 || maxBPtIndices[1] < 0 || maxBPtIndices[2] < 0)
156  return;
157  massBTopQuark_ = (jets[maxBPtIndices[0]].p4() + jets[maxBPtIndices[1]].p4() +
158  jets[maxBPtIndices[2]].p4()).mass();
159 }
int maxNJets_
max. number of jets to be considered
vector< PseudoJet > jets
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
bool failed_
indicate failed associations
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
double massBTopQuark_
cache of b-tagged top quark mass estimate
double Calculate::tmassTopQuark ( reco::RecoCandidate lep,
const reco::MET met,
const reco::Jet b 
)

calculate top quark transverse mass estimate

Definition at line 35 of file TopDQMHelpers.cc.

References operator()(), and tmassTopQuark_.

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

36  {
37  if (tmassTopQuark_ < 0) operator()(b, lepton, met);
38  return tmassTopQuark_;
39 }
double tmassTopQuark_
cache of top quark transverse mass estimate
void operator()(const std::vector< reco::Jet > &jets)
double Calculate::tmassWBoson ( reco::RecoCandidate lep,
const reco::MET met,
const reco::Jet b 
)

calculate W boson transverse mass estimate

Definition at line 29 of file TopDQMHelpers.cc.

References operator()(), and tmassWBoson_.

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

30  {
31  if (tmassWBoson_ < 0) operator()(b, mu, met);
32  return tmassWBoson_;
33 }
const int mu
Definition: Constants.h:22
void operator()(const std::vector< reco::Jet > &jets)
double tmassWBoson_
cache of W boson transverse mass estimate

Member Data Documentation

bool Calculate::failed_
private

indicate failed associations

Definition at line 105 of file TopDQMHelpers.h.

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

double Calculate::massBTopQuark_
private

cache of b-tagged top quark mass estimate

Definition at line 115 of file TopDQMHelpers.h.

Referenced by massBTopQuark(), and operator2().

double Calculate::massTopQuark_
private

cache of top quark mass estimate

Definition at line 113 of file TopDQMHelpers.h.

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

double Calculate::massWBoson_
private

cache of w boson mass estimate

Definition at line 111 of file TopDQMHelpers.h.

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

int Calculate::maxNJets_
private

max. number of jets to be considered

Definition at line 107 of file TopDQMHelpers.h.

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

double Calculate::tmassTopQuark_
private

cache of top quark transverse mass estimate

Definition at line 119 of file TopDQMHelpers.h.

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

double Calculate::tmassWBoson_
private

cache of W boson transverse mass estimate

Definition at line 117 of file TopDQMHelpers.h.

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

double Calculate::wMass_
private

paramater of the w boson mass

Definition at line 109 of file TopDQMHelpers.h.

Referenced by operator()().