1 #ifndef CovarianceMatrix_h
2 #define CovarianceMatrix_h
35 CovarianceMatrix(
const std::vector<edm::ParameterSet> udscResolutions,
const std::vector<edm::ParameterSet> bResolutions){
36 for(std::vector<edm::ParameterSet>::const_iterator iSet = udscResolutions.begin(); iSet != udscResolutions.end(); ++iSet){
37 if(iSet->exists(
"bin"))
binsUdsc_.push_back(iSet->getParameter<std::string>(
"bin"));
38 else if(udscResolutions.size()==1)
binsUdsc_.push_back(
"");
39 else throw cms::Exception(
"WrongConfig") <<
"Parameter 'bin' is needed if more than one PSet is specified!\n";
41 funcEtUdsc_.push_back(iSet->getParameter<std::string>(
"et"));
42 funcEtaUdsc_.push_back(iSet->getParameter<std::string>(
"eta"));
43 funcPhiUdsc_.push_back(iSet->getParameter<std::string>(
"phi"));
45 for(std::vector<edm::ParameterSet>::const_iterator iSet = bResolutions.begin(); iSet != bResolutions.end(); ++iSet){
46 if(iSet->exists(
"bin"))
binsB_.push_back(iSet->getParameter<std::string>(
"bin"));
47 else if(bResolutions.size()==1)
binsB_.push_back(
"");
48 else throw cms::Exception(
"WrongConfig") <<
"Parameter 'bin' is needed if more than one PSet is specified!\n";
50 funcEtB_.push_back(iSet->getParameter<std::string>(
"et"));
51 funcEtaB_.push_back(iSet->getParameter<std::string>(
"eta"));
52 funcPhiB_.push_back(iSet->getParameter<std::string>(
"phi"));
55 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){
56 for(std::vector<edm::ParameterSet>::const_iterator iSet = udscResolutions.begin(); iSet != udscResolutions.end(); ++iSet){
57 if(iSet->exists(
"bin"))
binsUdsc_.push_back(iSet->getParameter<std::string>(
"bin"));
58 else if(udscResolutions.size()==1)
binsUdsc_.push_back(
"");
59 else throw cms::Exception(
"WrongConfig") <<
"Parameter 'bin' is needed if more than one PSet is specified!\n";
61 funcEtUdsc_.push_back(iSet->getParameter<std::string>(
"et"));
62 funcEtaUdsc_.push_back(iSet->getParameter<std::string>(
"eta"));
63 funcPhiUdsc_.push_back(iSet->getParameter<std::string>(
"phi"));
65 for(std::vector<edm::ParameterSet>::const_iterator iSet = bResolutions.begin(); iSet != bResolutions.end(); ++iSet){
66 if(iSet->exists(
"bin"))
binsB_.push_back(iSet->getParameter<std::string>(
"bin"));
67 else if(bResolutions.size()==1)
binsB_.push_back(
"");
68 else throw cms::Exception(
"WrongConfig") <<
"Parameter 'bin' is needed if more than one PSet is specified!\n";
70 funcEtB_.push_back(iSet->getParameter<std::string>(
"et"));
71 funcEtaB_.push_back(iSet->getParameter<std::string>(
"eta"));
72 funcPhiB_.push_back(iSet->getParameter<std::string>(
"phi"));
74 for(std::vector<edm::ParameterSet>::const_iterator iSet = lepResolutions.begin(); iSet != lepResolutions.end(); ++iSet){
75 if(iSet->exists(
"bin"))
binsLep_.push_back(iSet->getParameter<std::string>(
"bin"));
76 else if(lepResolutions.size()==1)
binsLep_.push_back(
"");
77 else throw cms::Exception(
"WrongConfig") <<
"Parameter 'bin' is needed if more than one PSet is specified!\n";
79 funcEtLep_.push_back(iSet->getParameter<std::string>(
"et"));
80 funcEtaLep_.push_back(iSet->getParameter<std::string>(
"eta"));
81 funcPhiLep_.push_back(iSet->getParameter<std::string>(
"phi"));
83 for(std::vector<edm::ParameterSet>::const_iterator iSet = metResolutions.begin(); iSet != metResolutions.end(); ++iSet){
84 if(iSet->exists(
"bin"))
binsMet_.push_back(iSet->getParameter<std::string>(
"bin"));
85 else if(metResolutions.size()==1)
binsMet_.push_back(
"");
86 else throw cms::Exception(
"WrongConfig") <<
"Parameter 'bin' is needed if more than one PSet is specified!\n";
88 funcEtMet_.push_back(iSet->getParameter<std::string>(
"et"));
89 funcEtaMet_.push_back(iSet->getParameter<std::string>(
"eta"));
90 funcPhiMet_.push_back(iSet->getParameter<std::string>(
"phi"));
95 template <
class ObjectType>
98 template <
class ObjectType>
102 template <
class ObjectType>
105 std::vector<std::string> * bins_, * funcEt_, * funcEta_, * funcPhi_;
107 if( dynamic_cast<const reco::Jet*>(&
object) && !isBJet ) {
113 else if( dynamic_cast<const reco::Jet*>(&
object) && isBJet ) {
119 else if( dynamic_cast<const reco::Muon*>(&
object) || dynamic_cast<const reco::GsfElectron*>(&
object) ) {
125 else if( dynamic_cast<const reco::MET*>(&
object) ) {
132 throw cms::Exception(
"UnsupportedObject") <<
"The object given is not supported!\n";
137 for(
unsigned int i=0;
i<bins_->size(); ++
i){
140 if(select_(candidate)){
149 else throw cms::Exception(
"ProgrammingError") <<
"Only 'et', 'eta' and 'phi' resolutions supported!\n";
155 template <
class ObjectType>
158 TMatrixD CovM3 (3,3); CovM3.Zero();
159 TMatrixD CovM4 (4,4); CovM4.Zero();
160 TMatrixD* CovM = &CovM3;
162 if(
object.hasKinResolution())
166 CovM3(0,0) =
pow(
object.resolEt(resolutionProvider) , 2);
167 if( dynamic_cast<const reco::MET*>(&
object) ) CovM3(1,1) =
pow(9999., 2);
168 else CovM3(1,1) =
pow(
object.resolEta(resolutionProvider), 2);
169 CovM3(2,2) =
pow(
object.resolPhi(resolutionProvider), 2);
173 CovM3(0,0) =
pow(
object.resolEt(resolutionProvider) , 2);
174 CovM3(1,1) =
pow(
object.resolTheta(resolutionProvider), 2);
175 CovM3(2,2) =
pow(
object.resolPhi(resolutionProvider) , 2);
179 CovM4(0,0) =
pow(1, 2);
180 CovM4(1,1) =
pow(1, 2);
181 CovM4(2,2) =
pow(1, 2);
182 CovM4(3,3) =
pow(1, 2);
190 double pt =
object.pt(),
eta =
object.eta();
192 if( dynamic_cast<const reco::Jet*>(&
object) ) {
196 if(resolutionProvider ==
"bjets") {
211 if(resolutionProvider ==
"bjets") {
238 if(resolutionProvider ==
"bjets") {
253 else if( dynamic_cast<const reco::GsfElectron*>(&
object) ) {
257 CovM3(0,0) =
pow(elecRes.
a (pt,
eta), 2);
258 CovM3(1,1) =
pow(elecRes.
b (pt,
eta), 2);
259 CovM3(2,2) =
pow(elecRes.
c (pt,
eta), 2);
264 CovM3(0,0) =
pow(elecRes.
et (pt,
eta), 2);
265 CovM3(1,1) =
pow(elecRes.
eta(pt,
eta), 2);
266 CovM3(2,2) =
pow(elecRes.
phi(pt,
eta), 2);
276 CovM3(0,0) =
pow(elecRes.
et (pt,
eta), 2);
278 CovM3(2,2) =
pow(elecRes.
phi (pt,
eta), 2);
284 else if( dynamic_cast<const reco::Muon*>(&
object) ) {
288 CovM3(0,0) =
pow(muonRes.
a (pt,
eta), 2);
289 CovM3(1,1) =
pow(muonRes.
b (pt,
eta), 2);
290 CovM3(2,2) =
pow(muonRes.
c (pt,
eta), 2);
295 CovM3(0,0) =
pow(muonRes.
et (pt,
eta), 2);
296 CovM3(1,1) =
pow(muonRes.
eta(pt,
eta), 2);
297 CovM3(2,2) =
pow(muonRes.
phi(pt,
eta), 2);
307 CovM3(0,0) =
pow(muonRes.
et (pt,
eta), 2);
309 CovM3(2,2) =
pow(muonRes.
phi (pt,
eta), 2);
315 else if( dynamic_cast<const reco::MET*>(&
object) ) {
319 CovM3(0,0) =
pow(metRes.
a(pt), 2);
320 CovM3(1,1) =
pow(metRes.
b(pt), 2);
321 CovM3(2,2) =
pow(metRes.
c(pt), 2);
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);
338 CovM3(0,0) =
pow(metRes.
et(pt) , 2);
339 CovM3(1,1) =
pow( 9999. , 2);
340 CovM3(2,2) =
pow(metRes.
phi(pt), 2);
Param
supported parameterizations
double c(double pt, double eta)
std::vector< std::string > binsB_
double et(double pt, double eta)
double phi(double pt, double eta, Flavor flav)
double phi(double pt, double eta)
std::vector< std::string > funcEtUdsc_
vectors for the resolution functions
double b(double pt, double eta)
std::vector< std::string > binsMet_
double theta(double pt, double eta, Flavor flav)
double c(double pt, double eta)
TMatrixD setupMatrix(const pat::PATObject< ObjectType > &object, TopKinFitter::Param param, std::string resolutionProvider)
double eta(double pt, double eta)
CovarianceMatrix(const std::vector< edm::ParameterSet > udscResolutions, const std::vector< edm::ParameterSet > bResolutions)
double et(double pt, double eta, Flavor flav)
double getResolution(const pat::PATObject< ObjectType > &object, const std::string whichResolution, bool isBJet)
std::vector< std::string > funcEtB_
std::vector< std::string > binsUdsc_
vector of strings for the binning of the resolutions
std::vector< std::string > funcPhiB_
double b(double pt, double eta, Flavor flav)
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)
double d(double pt, double eta, Flavor flav)
std::vector< std::string > funcEtaB_
double a(double pt, double eta)
double theta(double pt, double eta)
double et(double pt, double eta)
std::vector< std::string > funcPhiUdsc_
std::vector< std::string > funcPhiLep_
double eta(double pt, double eta, Flavor flav)
std::vector< std::string > funcEtaUdsc_
std::vector< std::string > funcEtLep_
double theta(double pt, double eta)
std::vector< std::string > funcEtMet_
double eta(double pt, double eta)
double a(double pt, double eta)
std::vector< std::string > funcEtaLep_
std::vector< std::string > binsLep_
Templated PAT object container.
double c(double pt, double eta, Flavor flav)
std::vector< std::string > funcEtaMet_
double phi(double pt, double eta)
std::vector< std::string > funcPhiMet_
double a(double pt, double eta, Flavor flav)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Power< A, B >::type pow(const A &a, const B &b)
double b(double pt, double eta)