CMS 3D CMS Logo

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

#include <CovarianceMatrix.h>

Public Types

enum  ObjectType {
  kUdscJet, kBJet, kMuon, kElectron,
  kMet
}
 

Public Member Functions

 CovarianceMatrix ()
 default constructor More...
 
 CovarianceMatrix (const std::vector< edm::ParameterSet > &udscResolutions, const std::vector< edm::ParameterSet > &bResolutions, const std::vector< double > &jetEnergyResolutionScaleFactors, const std::vector< double > &jetEnergyResolutionEtaBinning)
 constructor for the fully-hadronic channel More...
 
 CovarianceMatrix (const std::vector< edm::ParameterSet > &udscResolutions, const std::vector< edm::ParameterSet > &bResolutions, const std::vector< edm::ParameterSet > &lepResolutions, const std::vector< edm::ParameterSet > &metResolutions, const std::vector< double > &jetEnergyResolutionScaleFactors, const std::vector< double > &jetEnergyResolutionEtaBinning)
 constructor for the lepton+jets channel More...
 
template<class T >
double getResolution (const pat::PATObject< T > &object, const std::string &whichResolution, const bool isBJet=false)
 get resolution for a given PAT object More...
 
double getResolution (const TLorentzVector &object, const ObjectType objType, const std::string &whichResolution="")
 get resolution for a given component of an object More...
 
template<class T >
TMatrixD setupMatrix (const pat::PATObject< T > &object, const TopKinFitter::Param param, const std::string &resolutionProvider="")
 return covariance matrix for a PAT object More...
 
TMatrixD setupMatrix (const TLorentzVector &object, const ObjectType objType, const TopKinFitter::Param param)
 return covariance matrix for a plain 4-vector More...
 
 ~CovarianceMatrix ()
 

Private Member Functions

template<class T >
double getEtaDependentScaleFactor (const pat::PATObject< T > &object)
 get eta dependent smear factor for a PAT object More...
 
double getEtaDependentScaleFactor (const TLorentzVector &object)
 get eta-dependent scale factor for a plain 4-vector More...
 
template<class T >
ObjectType getObjectType (const pat::PATObject< T > &object, const bool isBJet=false)
 determine type for a given PAT object More...
 

Private Attributes

std::vector< std::string > binsB_
 
std::vector< std::string > binsLep_
 
std::vector< std::string > binsMet_
 
std::vector< std::string > binsUdsc_
 vector of strings for the binning of the resolutions More...
 
std::vector< std::string > funcEtaB_
 
std::vector< std::string > funcEtaLep_
 
std::vector< std::string > funcEtaMet_
 
std::vector< std::string > funcEtaUdsc_
 
std::vector< std::string > funcEtB_
 
std::vector< std::string > funcEtLep_
 
std::vector< std::string > funcEtMet_
 
std::vector< std::string > funcEtUdsc_
 vectors for the resolution functions More...
 
std::vector< std::string > funcPhiB_
 
std::vector< std::string > funcPhiLep_
 
std::vector< std::string > funcPhiMet_
 
std::vector< std::string > funcPhiUdsc_
 
const std::vector< double > jetEnergyResolutionEtaBinning_
 
const std::vector< double > jetEnergyResolutionScaleFactors_
 scale factors for the jet energy resolution More...
 

Detailed Description

Definition at line 28 of file CovarianceMatrix.h.

Member Enumeration Documentation

◆ ObjectType

enum CovarianceMatrix::ObjectType
Enumerator
kUdscJet 
kBJet 
kMuon 
kElectron 
kMet 

Definition at line 30 of file CovarianceMatrix.h.

Constructor & Destructor Documentation

◆ CovarianceMatrix() [1/3]

CovarianceMatrix::CovarianceMatrix ( )
inline

default constructor

Definition at line 33 of file CovarianceMatrix.h.

33 {};

◆ CovarianceMatrix() [2/3]

CovarianceMatrix::CovarianceMatrix ( const std::vector< edm::ParameterSet > &  udscResolutions,
const std::vector< edm::ParameterSet > &  bResolutions,
const std::vector< double > &  jetEnergyResolutionScaleFactors,
const std::vector< double > &  jetEnergyResolutionEtaBinning 
)

constructor for the fully-hadronic channel

Definition at line 7 of file CovarianceMatrix.cc.

13  for (std::vector<edm::ParameterSet>::const_iterator iSet = udscResolutions.begin(); iSet != udscResolutions.end();
14  ++iSet) {
15  if (iSet->exists("bin"))
16  binsUdsc_.push_back(iSet->getParameter<std::string>("bin"));
17  else if (udscResolutions.size() == 1)
18  binsUdsc_.push_back("");
19  else
20  throw cms::Exception("Configuration") << "Parameter 'bin' is needed if more than one PSet is specified!\n";
21 
22  funcEtUdsc_.push_back(iSet->getParameter<std::string>("et"));
23  funcEtaUdsc_.push_back(iSet->getParameter<std::string>("eta"));
24  funcPhiUdsc_.push_back(iSet->getParameter<std::string>("phi"));
25  }
26  for (std::vector<edm::ParameterSet>::const_iterator iSet = bResolutions.begin(); iSet != bResolutions.end(); ++iSet) {
27  if (iSet->exists("bin"))
28  binsB_.push_back(iSet->getParameter<std::string>("bin"));
29  else if (bResolutions.size() == 1)
30  binsB_.push_back("");
31  else
32  throw cms::Exception("Configuration") << "Parameter 'bin' is needed if more than one PSet is specified!\n";
33 
34  funcEtB_.push_back(iSet->getParameter<std::string>("et"));
35  funcEtaB_.push_back(iSet->getParameter<std::string>("eta"));
36  funcPhiB_.push_back(iSet->getParameter<std::string>("phi"));
37  }
38 }

References binsB_, binsUdsc_, TtFullHadKinFitProducer_cfi::bResolutions, Exception, funcEtaB_, funcEtaUdsc_, funcEtB_, funcEtUdsc_, funcPhiB_, funcPhiUdsc_, AlCaHLTBitMon_QueryRunRegistry::string, and TtFullHadKinFitProducer_cfi::udscResolutions.

◆ CovarianceMatrix() [3/3]

CovarianceMatrix::CovarianceMatrix ( const std::vector< edm::ParameterSet > &  udscResolutions,
const std::vector< edm::ParameterSet > &  bResolutions,
const std::vector< edm::ParameterSet > &  lepResolutions,
const std::vector< edm::ParameterSet > &  metResolutions,
const std::vector< double > &  jetEnergyResolutionScaleFactors,
const std::vector< double > &  jetEnergyResolutionEtaBinning 
)

constructor for the lepton+jets channel

Definition at line 40 of file CovarianceMatrix.cc.

49  throw cms::Exception("Configuration") << "The number of scale factors does not fit to the number of eta bins!\n";
50  for (unsigned int i = 0; i < jetEnergyResolutionEtaBinning_.size(); i++)
52  throw cms::Exception("Configuration") << "eta binning in absolut values required!\n";
53 
54  for (std::vector<edm::ParameterSet>::const_iterator iSet = udscResolutions.begin(); iSet != udscResolutions.end();
55  ++iSet) {
56  if (iSet->exists("bin"))
57  binsUdsc_.push_back(iSet->getParameter<std::string>("bin"));
58  else if (udscResolutions.size() == 1)
59  binsUdsc_.push_back("");
60  else
61  throw cms::Exception("Configuration") << "Parameter 'bin' is needed if more than one PSet is specified!\n";
62 
63  funcEtUdsc_.push_back(iSet->getParameter<std::string>("et"));
64  funcEtaUdsc_.push_back(iSet->getParameter<std::string>("eta"));
65  funcPhiUdsc_.push_back(iSet->getParameter<std::string>("phi"));
66  }
67  for (std::vector<edm::ParameterSet>::const_iterator iSet = bResolutions.begin(); iSet != bResolutions.end(); ++iSet) {
68  if (iSet->exists("bin"))
69  binsB_.push_back(iSet->getParameter<std::string>("bin"));
70  else if (bResolutions.size() == 1)
71  binsB_.push_back("");
72  else
73  throw cms::Exception("Configuration") << "Parameter 'bin' is needed if more than one PSet is specified!\n";
74 
75  funcEtB_.push_back(iSet->getParameter<std::string>("et"));
76  funcEtaB_.push_back(iSet->getParameter<std::string>("eta"));
77  funcPhiB_.push_back(iSet->getParameter<std::string>("phi"));
78  }
79  for (std::vector<edm::ParameterSet>::const_iterator iSet = lepResolutions.begin(); iSet != lepResolutions.end();
80  ++iSet) {
81  if (iSet->exists("bin"))
82  binsLep_.push_back(iSet->getParameter<std::string>("bin"));
83  else if (lepResolutions.size() == 1)
84  binsLep_.push_back("");
85  else
86  throw cms::Exception("Configuration") << "Parameter 'bin' is needed if more than one PSet is specified!\n";
87 
88  funcEtLep_.push_back(iSet->getParameter<std::string>("et"));
89  funcEtaLep_.push_back(iSet->getParameter<std::string>("eta"));
90  funcPhiLep_.push_back(iSet->getParameter<std::string>("phi"));
91  }
92  for (std::vector<edm::ParameterSet>::const_iterator iSet = metResolutions.begin(); iSet != metResolutions.end();
93  ++iSet) {
94  if (iSet->exists("bin"))
95  binsMet_.push_back(iSet->getParameter<std::string>("bin"));
96  else if (metResolutions.size() == 1)
97  binsMet_.push_back("");
98  else
99  throw cms::Exception("Configuration") << "Parameter 'bin' is needed if more than one PSet is specified!\n";
100 
101  funcEtMet_.push_back(iSet->getParameter<std::string>("et"));
102  funcEtaMet_.push_back(iSet->getParameter<std::string>("eta"));
103  funcPhiMet_.push_back(iSet->getParameter<std::string>("phi"));
104  }
105 }

References binsB_, binsLep_, binsMet_, binsUdsc_, TtFullHadKinFitProducer_cfi::bResolutions, Exception, funcEtaB_, funcEtaLep_, funcEtaMet_, funcEtaUdsc_, funcEtB_, funcEtLep_, funcEtMet_, funcEtUdsc_, funcPhiB_, funcPhiLep_, funcPhiMet_, funcPhiUdsc_, mps_fire::i, jetEnergyResolutionEtaBinning_, jetEnergyResolutionScaleFactors_, AlCaHLTBitMon_QueryRunRegistry::string, and TtFullHadKinFitProducer_cfi::udscResolutions.

◆ ~CovarianceMatrix()

CovarianceMatrix::~CovarianceMatrix ( )
inline

Definition at line 47 of file CovarianceMatrix.h.

47 {};

Member Function Documentation

◆ getEtaDependentScaleFactor() [1/2]

template<class T >
double CovarianceMatrix::getEtaDependentScaleFactor ( const pat::PATObject< T > &  object)
private

get eta dependent smear factor for a PAT object

Definition at line 162 of file CovarianceMatrix.h.

162  {
163  double etaDependentScaleFactor = 1.;
164  for (unsigned int i = 0; i < jetEnergyResolutionEtaBinning_.size(); i++) {
166  if (i == jetEnergyResolutionEtaBinning_.size() - 1) {
167  edm::LogWarning("CovarianceMatrix") << "object eta (" << std::abs(object.eta()) << ") beyond last eta bin ("
168  << jetEnergyResolutionEtaBinning_[i] << ") using scale factor 1.0!";
169  etaDependentScaleFactor = 1.;
170  break;
171  }
172  etaDependentScaleFactor = jetEnergyResolutionScaleFactors_[i];
173  } else
174  break;
175  }
176  return etaDependentScaleFactor;
177 }

References funct::abs(), PVValHelper::eta, mps_fire::i, jetEnergyResolutionEtaBinning_, and jetEnergyResolutionScaleFactors_.

Referenced by setupMatrix().

◆ getEtaDependentScaleFactor() [2/2]

double CovarianceMatrix::getEtaDependentScaleFactor ( const TLorentzVector &  object)
private

get eta-dependent scale factor for a plain 4-vector

Definition at line 338 of file CovarianceMatrix.cc.

338  {
339  double etaDependentScaleFactor = 1.;
340  for (unsigned int i = 0; i < jetEnergyResolutionEtaBinning_.size(); i++) {
342  if (i == jetEnergyResolutionEtaBinning_.size() - 1) {
343  edm::LogWarning("CovarianceMatrix") << "object eta (" << std::abs(object.Eta()) << ") beyond last eta bin ("
344  << jetEnergyResolutionEtaBinning_[i] << ") using scale factor 1.0!";
345  etaDependentScaleFactor = 1.;
346  break;
347  }
348  etaDependentScaleFactor = jetEnergyResolutionScaleFactors_[i];
349  } else
350  break;
351  }
352  return etaDependentScaleFactor;
353 }

References funct::abs(), mps_fire::i, jetEnergyResolutionEtaBinning_, and jetEnergyResolutionScaleFactors_.

◆ getObjectType()

template<class T >
CovarianceMatrix::ObjectType CovarianceMatrix::getObjectType ( const pat::PATObject< T > &  object,
const bool  isBJet = false 
)
private

determine type for a given PAT object

Definition at line 137 of file CovarianceMatrix.h.

137  {
139  // jets
140  if (dynamic_cast<const reco::Jet*>(&object)) {
141  if (isBJet)
142  objType = kBJet;
143  else
144  objType = kUdscJet;
145  }
146  // muons
147  else if (dynamic_cast<const reco::Muon*>(&object))
148  objType = kMuon;
149  // electrons
150  else if (dynamic_cast<const reco::GsfElectron*>(&object))
151  objType = kElectron;
152  // MET
153  else if (dynamic_cast<const reco::MET*>(&object))
154  objType = kMet;
155  // catch anything else
156  else
157  throw cms::Exception("UnsupportedObject") << "The object given is not supported!\n";
158  return objType;
159 }

References Exception, kBJet, kElectron, kMet, kMuon, kUdscJet, and electrons_cff::objType.

Referenced by getResolution(), and setupMatrix().

◆ getResolution() [1/2]

template<class T >
double CovarianceMatrix::getResolution ( const pat::PATObject< T > &  object,
const std::string &  whichResolution,
const bool  isBJet = false 
)
inline

get resolution for a given PAT object

Definition at line 60 of file CovarianceMatrix.h.

60  {
61  return getResolution(TLorentzVector(object.px(), object.py(), object.pz(), object.energy()),
62  getObjectType(object, isBJet),
63  whichResolution);
64  }

References HCALHighEnergyHPDFilter_cfi::energy, getObjectType(), getResolution(), multPhiCorr_741_25nsDY_cfi::px, and multPhiCorr_741_25nsDY_cfi::py.

◆ getResolution() [2/2]

double CovarianceMatrix::getResolution ( const TLorentzVector &  object,
const ObjectType  objType,
const std::string &  whichResolution = "" 
)

get resolution for a given component of an object

Definition at line 107 of file CovarianceMatrix.cc.

109  {
110  std::vector<std::string>*bins_, *funcEt_, *funcEta_, *funcPhi_;
111 
112  switch (objType) {
113  case kUdscJet:
114  bins_ = &binsUdsc_;
115  funcEt_ = &funcEtUdsc_;
116  funcEta_ = &funcEtaUdsc_;
117  funcPhi_ = &funcPhiUdsc_;
118  break;
119  case kBJet:
120  bins_ = &binsB_;
121  funcEt_ = &funcEtB_;
122  funcEta_ = &funcEtaB_;
123  funcPhi_ = &funcPhiB_;
124  break;
125  case kMuon:
126  bins_ = &binsLep_;
127  funcEt_ = &funcEtLep_;
128  funcEta_ = &funcEtaLep_;
129  funcPhi_ = &funcPhiLep_;
130  break;
131  case kElectron:
132  bins_ = &binsLep_;
133  funcEt_ = &funcEtLep_;
134  funcEta_ = &funcEtaLep_;
135  funcPhi_ = &funcPhiLep_;
136  break;
137  case kMet:
138  bins_ = &binsMet_;
139  funcEt_ = &funcEtMet_;
140  funcEta_ = &funcEtaMet_;
141  funcPhi_ = &funcPhiMet_;
142  break;
143  default:
144  throw cms::Exception("UnsupportedObject") << "The object given is not supported!\n";
145  }
146 
147  int selectedBin = -1;
148  reco::LeafCandidate candidate;
149  for (unsigned int i = 0; i < bins_->size(); ++i) {
151  candidate = reco::LeafCandidate(
152  0, reco::LeafCandidate::LorentzVector(object.Px(), object.Py(), object.Pz(), object.Energy()));
153  if (select_(candidate)) {
154  selectedBin = i;
155  break;
156  }
157  }
158  double res = 0;
159  if (selectedBin >= 0) {
160  if (whichResolution == "et")
161  res = StringObjectFunction<reco::LeafCandidate>(funcEt_->at(selectedBin)).operator()(candidate);
162  else if (whichResolution == "eta")
163  res = StringObjectFunction<reco::LeafCandidate>(funcEta_->at(selectedBin)).operator()(candidate);
164  else if (whichResolution == "phi")
165  res = StringObjectFunction<reco::LeafCandidate>(funcPhi_->at(selectedBin)).operator()(candidate);
166  else
167  throw cms::Exception("ProgrammingError") << "Only 'et', 'eta' and 'phi' resolutions supported!\n";
168  }
169  return res;
170 }

References binsB_, binsLep_, binsMet_, binsUdsc_, EcalCondDBWriter_cfi::Energy, Exception, funcEtaB_, funcEtaLep_, funcEtaMet_, funcEtaUdsc_, funcEtB_, funcEtLep_, funcEtMet_, funcEtUdsc_, funcPhiB_, funcPhiLep_, funcPhiMet_, funcPhiUdsc_, mps_fire::i, kBJet, kElectron, kMet, kMuon, kUdscJet, and electrons_cff::objType.

Referenced by getResolution(), and setupMatrix().

◆ setupMatrix() [1/2]

template<class T >
TMatrixD CovarianceMatrix::setupMatrix ( const pat::PATObject< T > &  object,
const TopKinFitter::Param  param,
const std::string &  resolutionProvider = "" 
)

return covariance matrix for a PAT object

Definition at line 88 of file CovarianceMatrix.h.

90  {
91  // This part is for pat objects with resolutions embedded
92  if (object.hasKinResolution()) {
93  TMatrixD CovM3(3, 3);
94  CovM3.Zero();
95  TMatrixD CovM4(4, 4);
96  CovM4.Zero();
97  TMatrixD* CovM = &CovM3;
98  switch (param) {
100  CovM3(0, 0) = pow(object.resolEt(resolutionProvider), 2);
101  if (dynamic_cast<const reco::Jet*>(&object))
102  CovM3(0, 0) *= getEtaDependentScaleFactor(object);
103  if (dynamic_cast<const reco::MET*>(&object))
104  CovM3(1, 1) = pow(9999., 2);
105  else
106  CovM3(1, 1) = pow(object.resolEta(resolutionProvider), 2);
107  CovM3(2, 2) = pow(object.resolPhi(resolutionProvider), 2);
108  CovM = &CovM3;
109  break;
111  CovM3(0, 0) = pow(object.resolEt(resolutionProvider), 2);
112  if (dynamic_cast<const reco::Jet*>(&object))
113  CovM3(0, 0) *= getEtaDependentScaleFactor(object);
114  CovM3(1, 1) = pow(object.resolTheta(resolutionProvider), 2);
115  CovM3(2, 2) = pow(object.resolPhi(resolutionProvider), 2);
116  CovM = &CovM3;
117  break;
118  case TopKinFitter::kEMom:
119  CovM4(0, 0) = pow(1, 2);
120  CovM4(1, 1) = pow(1, 2);
121  CovM4(2, 2) = pow(1, 2);
122  CovM4(3, 3) = pow(1, 2);
123  CovM = &CovM4;
124  break;
125  }
126  return *CovM;
127  }
128  // This part is for objects without resolutions embedded
129  else {
130  const ObjectType objType = getObjectType(object, (resolutionProvider == "bjets"));
131  const TLorentzVector p4(object.px(), object.py(), object.pz(), object.energy());
132  return setupMatrix(p4, objType, param);
133  }
134 }

References HCALHighEnergyHPDFilter_cfi::energy, getEtaDependentScaleFactor(), getObjectType(), TopKinFitter::kEMom, TopKinFitter::kEtEtaPhi, TopKinFitter::kEtThetaPhi, electrons_cff::objType, p4, funct::pow(), multPhiCorr_741_25nsDY_cfi::px, and multPhiCorr_741_25nsDY_cfi::py.

Referenced by TtSemiLepKinFitter::fit(), and TtFullHadKinFitter::fit().

◆ setupMatrix() [2/2]

TMatrixD CovarianceMatrix::setupMatrix ( const TLorentzVector &  object,
const ObjectType  objType,
const TopKinFitter::Param  param 
)

return covariance matrix for a plain 4-vector

Definition at line 172 of file CovarianceMatrix.cc.

174  {
175  TMatrixD CovM3(3, 3);
176  CovM3.Zero();
177  TMatrixD CovM4(4, 4);
178  CovM4.Zero();
179  const double pt = object.Pt();
180  const double eta = object.Eta();
181  switch (objType) {
182  case kUdscJet:
183  // if object is a non-b jet
184  {
185  res::HelperJet jetRes;
186  switch (param) {
187  case TopKinFitter::kEMom:
188  CovM4(0, 0) = pow(jetRes.a(pt, eta, res::HelperJet::kUds), 2);
189  CovM4(1, 1) = pow(jetRes.b(pt, eta, res::HelperJet::kUds), 2);
190  CovM4(2, 2) = pow(jetRes.c(pt, eta, res::HelperJet::kUds), 2);
191  CovM4(3, 3) = pow(jetRes.d(pt, eta, res::HelperJet::kUds), 2);
192  return CovM4;
194  if (binsUdsc_.empty()) {
195  CovM3(0, 0) = pow(jetRes.et(pt, eta, res::HelperJet::kUds), 2);
196  CovM3(0, 0) *= pow(getEtaDependentScaleFactor(object), 2);
197  CovM3(1, 1) = pow(jetRes.eta(pt, eta, res::HelperJet::kUds), 2);
198  CovM3(2, 2) = pow(jetRes.phi(pt, eta, res::HelperJet::kUds), 2);
199  } else {
200  CovM3(0, 0) = pow(getResolution(object, objType, "et"), 2);
201  CovM3(0, 0) *= pow(getEtaDependentScaleFactor(object), 2);
202  CovM3(1, 1) = pow(getResolution(object, objType, "eta"), 2);
203  CovM3(2, 2) = pow(getResolution(object, objType, "phi"), 2);
204  }
205  return CovM3;
207  CovM3(0, 0) = pow(jetRes.et(pt, eta, res::HelperJet::kUds), 2);
208  CovM3(0, 0) *= pow(getEtaDependentScaleFactor(object), 2);
209  CovM3(1, 1) = pow(jetRes.theta(pt, eta, res::HelperJet::kUds), 2);
210  CovM3(2, 2) = pow(jetRes.phi(pt, eta, res::HelperJet::kUds), 2);
211  return CovM3;
212  }
213  }
214  break;
215  case kBJet:
216  // if object is a b jet
217  {
218  res::HelperJet jetRes;
219  switch (param) {
220  case TopKinFitter::kEMom:
221  CovM4(0, 0) = pow(jetRes.a(pt, eta, res::HelperJet::kB), 2);
222  CovM4(1, 1) = pow(jetRes.b(pt, eta, res::HelperJet::kB), 2);
223  CovM4(2, 2) = pow(jetRes.c(pt, eta, res::HelperJet::kB), 2);
224  CovM4(3, 3) = pow(jetRes.d(pt, eta, res::HelperJet::kB), 2);
225  return CovM4;
227  if (binsUdsc_.empty()) {
228  CovM3(0, 0) = pow(jetRes.et(pt, eta, res::HelperJet::kB), 2);
229  CovM3(0, 0) *= pow(getEtaDependentScaleFactor(object), 2);
230  CovM3(1, 1) = pow(jetRes.eta(pt, eta, res::HelperJet::kB), 2);
231  CovM3(2, 2) = pow(jetRes.phi(pt, eta, res::HelperJet::kB), 2);
232  } else {
233  CovM3(0, 0) = pow(getResolution(object, objType, "et"), 2);
234  CovM3(0, 0) *= pow(getEtaDependentScaleFactor(object), 2);
235  CovM3(1, 1) = pow(getResolution(object, objType, "eta"), 2);
236  CovM3(2, 2) = pow(getResolution(object, objType, "phi"), 2);
237  }
238  return CovM3;
240  CovM3(0, 0) = pow(jetRes.et(pt, eta, res::HelperJet::kB), 2);
241  CovM3(0, 0) *= pow(getEtaDependentScaleFactor(object), 2);
242  CovM3(1, 1) = pow(jetRes.theta(pt, eta, res::HelperJet::kB), 2);
243  CovM3(2, 2) = pow(jetRes.phi(pt, eta, res::HelperJet::kB), 2);
244  return CovM3;
245  }
246  }
247  break;
248  case kMuon:
249  // if object is a muon
250  {
251  res::HelperMuon muonRes;
252  switch (param) {
253  case TopKinFitter::kEMom:
254  CovM3(0, 0) = pow(muonRes.a(pt, eta), 2);
255  CovM3(1, 1) = pow(muonRes.b(pt, eta), 2);
256  CovM3(2, 2) = pow(muonRes.c(pt, eta), 2);
257  return CovM3;
259  if (binsLep_.empty()) {
260  CovM3(0, 0) = pow(muonRes.et(pt, eta), 2);
261  CovM3(1, 1) = pow(muonRes.eta(pt, eta), 2);
262  CovM3(2, 2) = pow(muonRes.phi(pt, eta), 2);
263  } else {
264  CovM3(0, 0) = pow(getResolution(object, objType, "et"), 2);
265  CovM3(1, 1) = pow(getResolution(object, objType, "eta"), 2);
266  CovM3(2, 2) = pow(getResolution(object, objType, "phi"), 2);
267  }
268  return CovM3;
270  CovM3(0, 0) = pow(muonRes.et(pt, eta), 2);
271  CovM3(1, 1) = pow(muonRes.theta(pt, eta), 2);
272  CovM3(2, 2) = pow(muonRes.phi(pt, eta), 2);
273  return CovM3;
274  }
275  }
276  break;
277  case kElectron: {
278  // if object is an electron
279  res::HelperElectron elecRes;
280  switch (param) {
281  case TopKinFitter::kEMom:
282  CovM3(0, 0) = pow(elecRes.a(pt, eta), 2);
283  CovM3(1, 1) = pow(elecRes.b(pt, eta), 2);
284  CovM3(2, 2) = pow(elecRes.c(pt, eta), 2);
285  return CovM3;
287  if (binsLep_.empty()) {
288  CovM3(0, 0) = pow(elecRes.et(pt, eta), 2);
289  CovM3(1, 1) = pow(elecRes.eta(pt, eta), 2);
290  CovM3(2, 2) = pow(elecRes.phi(pt, eta), 2);
291  } else {
292  CovM3(0, 0) = pow(getResolution(object, objType, "et"), 2);
293  CovM3(1, 1) = pow(getResolution(object, objType, "eta"), 2);
294  CovM3(2, 2) = pow(getResolution(object, objType, "phi"), 2);
295  }
296  return CovM3;
298  CovM3(0, 0) = pow(elecRes.et(pt, eta), 2);
299  CovM3(1, 1) = pow(elecRes.theta(pt, eta), 2);
300  CovM3(2, 2) = pow(elecRes.phi(pt, eta), 2);
301  return CovM3;
302  }
303  } break;
304  case kMet:
305  // if object is met
306  {
307  res::HelperMET metRes;
308  switch (param) {
309  case TopKinFitter::kEMom:
310  CovM3(0, 0) = pow(metRes.a(pt), 2);
311  CovM3(1, 1) = pow(metRes.b(pt), 2);
312  CovM3(2, 2) = pow(metRes.c(pt), 2);
313  return CovM3;
315  if (binsMet_.empty()) {
316  CovM3(0, 0) = pow(metRes.et(pt), 2);
317  CovM3(1, 1) = pow(9999., 2);
318  CovM3(2, 2) = pow(metRes.phi(pt), 2);
319  } else {
320  CovM3(0, 0) = pow(getResolution(object, objType, "et"), 2);
321  CovM3(1, 1) = pow(getResolution(object, objType, "eta"), 2);
322  CovM3(2, 2) = pow(getResolution(object, objType, "phi"), 2);
323  }
324  return CovM3;
326  CovM3(0, 0) = pow(metRes.et(pt), 2);
327  CovM3(1, 1) = pow(9999., 2);
328  CovM3(2, 2) = pow(metRes.phi(pt), 2);
329  return CovM3;
330  }
331  }
332  break;
333  }
334  cms::Exception("Logic") << "Something went wrong while trying to setup a covariance matrix!\n";
335  return CovM4; //should never get here
336 }

References res::HelperMET::a(), res::HelperMuon::a(), res::HelperElectron::a(), res::HelperJet::a(), res::HelperMET::b(), res::HelperElectron::b(), res::HelperMuon::b(), res::HelperJet::b(), binsLep_, binsMet_, binsUdsc_, res::HelperMET::c(), res::HelperElectron::c(), res::HelperMuon::c(), res::HelperJet::c(), res::HelperJet::d(), res::HelperElectron::et(), res::HelperMET::et(), res::HelperMuon::et(), res::HelperJet::et(), res::HelperElectron::eta(), res::HelperMuon::eta(), res::HelperJet::eta(), PVValHelper::eta, Exception, getEtaDependentScaleFactor(), getResolution(), res::HelperJet::kB, kBJet, kElectron, TopKinFitter::kEMom, TopKinFitter::kEtEtaPhi, TopKinFitter::kEtThetaPhi, kMet, kMuon, res::HelperJet::kUds, kUdscJet, electrons_cff::objType, res::HelperMuon::phi(), res::HelperElectron::phi(), res::HelperJet::phi(), res::HelperMET::phi(), funct::pow(), DiDispStaMuonMonitor_cfi::pt, res::HelperMuon::theta(), res::HelperElectron::theta(), and res::HelperJet::theta().

Member Data Documentation

◆ binsB_

std::vector<std::string> CovarianceMatrix::binsB_
private

Definition at line 68 of file CovarianceMatrix.h.

Referenced by CovarianceMatrix(), and getResolution().

◆ binsLep_

std::vector<std::string> CovarianceMatrix::binsLep_
private

Definition at line 68 of file CovarianceMatrix.h.

Referenced by CovarianceMatrix(), getResolution(), and setupMatrix().

◆ binsMet_

std::vector<std::string> CovarianceMatrix::binsMet_
private

Definition at line 68 of file CovarianceMatrix.h.

Referenced by CovarianceMatrix(), getResolution(), and setupMatrix().

◆ binsUdsc_

std::vector<std::string> CovarianceMatrix::binsUdsc_
private

vector of strings for the binning of the resolutions

Definition at line 68 of file CovarianceMatrix.h.

Referenced by CovarianceMatrix(), getResolution(), and setupMatrix().

◆ funcEtaB_

std::vector<std::string> CovarianceMatrix::funcEtaB_
private

Definition at line 71 of file CovarianceMatrix.h.

Referenced by CovarianceMatrix(), and getResolution().

◆ funcEtaLep_

std::vector<std::string> CovarianceMatrix::funcEtaLep_
private

Definition at line 71 of file CovarianceMatrix.h.

Referenced by CovarianceMatrix(), and getResolution().

◆ funcEtaMet_

std::vector<std::string> CovarianceMatrix::funcEtaMet_
private

Definition at line 71 of file CovarianceMatrix.h.

Referenced by CovarianceMatrix(), and getResolution().

◆ funcEtaUdsc_

std::vector<std::string> CovarianceMatrix::funcEtaUdsc_
private

Definition at line 71 of file CovarianceMatrix.h.

Referenced by CovarianceMatrix(), and getResolution().

◆ funcEtB_

std::vector<std::string> CovarianceMatrix::funcEtB_
private

Definition at line 70 of file CovarianceMatrix.h.

Referenced by CovarianceMatrix(), and getResolution().

◆ funcEtLep_

std::vector<std::string> CovarianceMatrix::funcEtLep_
private

Definition at line 70 of file CovarianceMatrix.h.

Referenced by CovarianceMatrix(), and getResolution().

◆ funcEtMet_

std::vector<std::string> CovarianceMatrix::funcEtMet_
private

Definition at line 70 of file CovarianceMatrix.h.

Referenced by CovarianceMatrix(), and getResolution().

◆ funcEtUdsc_

std::vector<std::string> CovarianceMatrix::funcEtUdsc_
private

vectors for the resolution functions

Definition at line 70 of file CovarianceMatrix.h.

Referenced by CovarianceMatrix(), and getResolution().

◆ funcPhiB_

std::vector<std::string> CovarianceMatrix::funcPhiB_
private

Definition at line 72 of file CovarianceMatrix.h.

Referenced by CovarianceMatrix(), and getResolution().

◆ funcPhiLep_

std::vector<std::string> CovarianceMatrix::funcPhiLep_
private

Definition at line 72 of file CovarianceMatrix.h.

Referenced by CovarianceMatrix(), and getResolution().

◆ funcPhiMet_

std::vector<std::string> CovarianceMatrix::funcPhiMet_
private

Definition at line 72 of file CovarianceMatrix.h.

Referenced by CovarianceMatrix(), and getResolution().

◆ funcPhiUdsc_

std::vector<std::string> CovarianceMatrix::funcPhiUdsc_
private

Definition at line 72 of file CovarianceMatrix.h.

Referenced by CovarianceMatrix(), and getResolution().

◆ jetEnergyResolutionEtaBinning_

const std::vector<double> CovarianceMatrix::jetEnergyResolutionEtaBinning_
private

Definition at line 75 of file CovarianceMatrix.h.

Referenced by CovarianceMatrix(), and getEtaDependentScaleFactor().

◆ jetEnergyResolutionScaleFactors_

const std::vector<double> CovarianceMatrix::jetEnergyResolutionScaleFactors_
private

scale factors for the jet energy resolution

Definition at line 74 of file CovarianceMatrix.h.

Referenced by CovarianceMatrix(), and getEtaDependentScaleFactor().

TopKinFitter::kEtEtaPhi
Definition: TopKinFitter.h:20
res::HelperElectron::et
double et(double pt, double eta)
Definition: Electron.h:185
CovarianceMatrix::jetEnergyResolutionScaleFactors_
const std::vector< double > jetEnergyResolutionScaleFactors_
scale factors for the jet energy resolution
Definition: CovarianceMatrix.h:74
CovarianceMatrix::funcPhiUdsc_
std::vector< std::string > funcPhiUdsc_
Definition: CovarianceMatrix.h:72
res::HelperMuon
Definition: Muon.h:7
res::HelperMET
Definition: MET.h:7
mps_fire.i
i
Definition: mps_fire.py:428
StringObjectFunction
Definition: StringObjectFunction.h:16
res::HelperMuon::c
double c(double pt, double eta)
Definition: Muon.h:79
EcalCondDBWriter_cfi.Energy
Energy
Definition: EcalCondDBWriter_cfi.py:152
res::HelperJet::c
double c(double pt, double eta, Flavor flav)
Definition: Jet.h:138
TtFullHadKinFitProducer_cfi.udscResolutions
udscResolutions
Definition: TtFullHadKinFitProducer_cfi.py:83
res::HelperMET::b
double b(double pt)
Definition: MET.h:31
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
multPhiCorr_741_25nsDY_cfi.py
py
Definition: multPhiCorr_741_25nsDY_cfi.py:12
res::HelperJet
Definition: Jet.h:7
CovarianceMatrix::funcEtMet_
std::vector< std::string > funcEtMet_
Definition: CovarianceMatrix.h:70
CovarianceMatrix::binsLep_
std::vector< std::string > binsLep_
Definition: CovarianceMatrix.h:68
CovarianceMatrix::funcPhiLep_
std::vector< std::string > funcPhiLep_
Definition: CovarianceMatrix.h:72
res::HelperMET::phi
double phi(double pt)
Definition: MET.h:51
res::HelperMET::et
double et(double pt)
Definition: MET.h:56
res::HelperMuon::b
double b(double pt, double eta)
Definition: Muon.h:54
res::HelperJet::phi
double phi(double pt, double eta, Flavor flav)
Definition: Jet.h:282
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
TopKinFitter::kEMom
Definition: TopKinFitter.h:20
res::HelperElectron::phi
double phi(double pt, double eta)
Definition: Electron.h:160
res::HelperMuon::theta
double theta(double pt, double eta)
Definition: Muon.h:129
res::HelperElectron::eta
double eta(double pt, double eta)
Definition: Electron.h:210
CovarianceMatrix::kElectron
Definition: CovarianceMatrix.h:30
CovarianceMatrix::funcPhiMet_
std::vector< std::string > funcPhiMet_
Definition: CovarianceMatrix.h:72
res::HelperJet::kB
Definition: Jet.h:9
CovarianceMatrix::funcEtaLep_
std::vector< std::string > funcEtaLep_
Definition: CovarianceMatrix.h:71
PVValHelper::eta
Definition: PVValidationHelpers.h:70
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
CovarianceMatrix::getResolution
double getResolution(const TLorentzVector &object, const ObjectType objType, const std::string &whichResolution="")
get resolution for a given component of an object
Definition: CovarianceMatrix.cc:107
res::HelperMuon::et
double et(double pt, double eta)
Definition: Muon.h:179
CovarianceMatrix::kBJet
Definition: CovarianceMatrix.h:30
res::HelperJet::d
double d(double pt, double eta, Flavor flav)
Definition: Jet.h:186
CovarianceMatrix::funcEtaMet_
std::vector< std::string > funcEtaMet_
Definition: CovarianceMatrix.h:71
CovarianceMatrix::kMet
Definition: CovarianceMatrix.h:30
CovarianceMatrix::binsB_
std::vector< std::string > binsB_
Definition: CovarianceMatrix.h:68
electrons_cff.objType
objType
Definition: electrons_cff.py:519
res::HelperMET::c
double c(double pt)
Definition: MET.h:36
CovarianceMatrix::jetEnergyResolutionEtaBinning_
const std::vector< double > jetEnergyResolutionEtaBinning_
Definition: CovarianceMatrix.h:75
res::HelperJet::b
double b(double pt, double eta, Flavor flav)
Definition: Jet.h:90
CovarianceMatrix::kMuon
Definition: CovarianceMatrix.h:30
res::HelperElectron
Definition: Electron.h:7
res::HelperJet::theta
double theta(double pt, double eta, Flavor flav)
Definition: Jet.h:234
p4
double p4[4]
Definition: TauolaWrapper.h:92
CovarianceMatrix::getEtaDependentScaleFactor
double getEtaDependentScaleFactor(const pat::PATObject< T > &object)
get eta dependent smear factor for a PAT object
Definition: CovarianceMatrix.h:162
CovarianceMatrix::funcEtUdsc_
std::vector< std::string > funcEtUdsc_
vectors for the resolution functions
Definition: CovarianceMatrix.h:70
res
Definition: Electron.h:6
TtFullHadKinFitProducer_cfi.jetEnergyResolutionEtaBinning
jetEnergyResolutionEtaBinning
Definition: TtFullHadKinFitProducer_cfi.py:95
TopKinFitter::kEtThetaPhi
Definition: TopKinFitter.h:20
TtFullHadKinFitProducer_cfi.jetEnergyResolutionScaleFactors
jetEnergyResolutionScaleFactors
Definition: TtFullHadKinFitProducer_cfi.py:94
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
multPhiCorr_741_25nsDY_cfi.px
px
Definition: multPhiCorr_741_25nsDY_cfi.py:10
CovarianceMatrix::funcEtB_
std::vector< std::string > funcEtB_
Definition: CovarianceMatrix.h:70
CovarianceMatrix::getObjectType
ObjectType getObjectType(const pat::PATObject< T > &object, const bool isBJet=false)
determine type for a given PAT object
Definition: CovarianceMatrix.h:137
res::HelperElectron::a
double a(double pt, double eta)
Definition: Electron.h:35
res::HelperMuon::eta
double eta(double pt, double eta)
Definition: Muon.h:204
res::HelperElectron::theta
double theta(double pt, double eta)
Definition: Electron.h:135
CovarianceMatrix::funcPhiB_
std::vector< std::string > funcPhiB_
Definition: CovarianceMatrix.h:72
StringCutObjectSelector
Definition: StringCutObjectSelector.h:16
Exception
Definition: hltDiff.cc:245
TtFullHadKinFitProducer_cfi.bResolutions
bResolutions
Definition: TtFullHadKinFitProducer_cfi.py:84
res::HelperJet::eta
double eta(double pt, double eta, Flavor flav)
Definition: Jet.h:378
CovarianceMatrix::kUdscJet
Definition: CovarianceMatrix.h:30
CovarianceMatrix::binsMet_
std::vector< std::string > binsMet_
Definition: CovarianceMatrix.h:68
res::HelperMuon::phi
double phi(double pt, double eta)
Definition: Muon.h:154
res::HelperElectron::b
double b(double pt, double eta)
Definition: Electron.h:60
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
CovarianceMatrix::setupMatrix
TMatrixD setupMatrix(const pat::PATObject< T > &object, const TopKinFitter::Param param, const std::string &resolutionProvider="")
return covariance matrix for a PAT object
Definition: CovarianceMatrix.h:88
CovarianceMatrix::binsUdsc_
std::vector< std::string > binsUdsc_
vector of strings for the binning of the resolutions
Definition: CovarianceMatrix.h:68
reco::LeafCandidate
Definition: LeafCandidate.h:16
cms::Exception
Definition: Exception.h:70
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
res::HelperMuon::a
double a(double pt, double eta)
Definition: Muon.h:29
CovarianceMatrix::ObjectType
ObjectType
Definition: CovarianceMatrix.h:30
res::HelperMET::a
double a(double pt)
Definition: MET.h:26
res::HelperJet::a
double a(double pt, double eta, Flavor flav)
Definition: Jet.h:42
res::HelperJet::et
double et(double pt, double eta, Flavor flav)
Definition: Jet.h:330
res::HelperJet::kUds
Definition: Jet.h:9
res::HelperElectron::c
double c(double pt, double eta)
Definition: Electron.h:85
CovarianceMatrix::funcEtaUdsc_
std::vector< std::string > funcEtaUdsc_
Definition: CovarianceMatrix.h:71
reco::LeafCandidate::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: LeafCandidate.h:23
CovarianceMatrix::funcEtLep_
std::vector< std::string > funcEtLep_
Definition: CovarianceMatrix.h:70
CovarianceMatrix::funcEtaB_
std::vector< std::string > funcEtaB_
Definition: CovarianceMatrix.h:71