Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:22

0001 #include <DataFormats/PatCandidates/interface/CandKinResolution.h>
0002 #include <DataFormats/PatCandidates/interface/ResolutionHelper.h>
0003 #include <DataFormats/PatCandidates/interface/ParametrizationHelper.h>
0004 
0005 pat::CandKinResolution::CandKinResolution() : parametrization_(Invalid), covariances_(), constraints_(), covmatrix_() {}
0006 
0007 pat::CandKinResolution::CandKinResolution(Parametrization parametrization,
0008                                           const std::vector<Scalar> &covariances,
0009                                           const std::vector<Scalar> &constraints)
0010     : parametrization_(parametrization), covariances_(covariances), constraints_(constraints), covmatrix_() {
0011   fillMatrix();
0012 }
0013 
0014 pat::CandKinResolution::CandKinResolution(Parametrization parametrization,
0015                                           const AlgebraicSymMatrix44 &covariance,
0016                                           const std::vector<Scalar> &constraints)
0017     : parametrization_(parametrization), covariances_(), constraints_(constraints), covmatrix_(covariance) {
0018   fillVector();
0019   if (sizeof(double) != sizeof(Scalar)) {  // should become boost::mpl::if_c
0020     fillMatrix();                          // forcing double => float => double conversion
0021   }
0022 }
0023 
0024 pat::CandKinResolution::~CandKinResolution() {}
0025 
0026 double pat::CandKinResolution::resolEta(const pat::CandKinResolution::LorentzVector &p4) const {
0027   return pat::helper::ResolutionHelper::getResolEta(parametrization_, covmatrix_, p4);
0028 }
0029 double pat::CandKinResolution::resolTheta(const pat::CandKinResolution::LorentzVector &p4) const {
0030   return pat::helper::ResolutionHelper::getResolTheta(parametrization_, covmatrix_, p4);
0031 }
0032 double pat::CandKinResolution::resolPhi(const pat::CandKinResolution::LorentzVector &p4) const {
0033   return pat::helper::ResolutionHelper::getResolPhi(parametrization_, covmatrix_, p4);
0034 }
0035 double pat::CandKinResolution::resolE(const pat::CandKinResolution::LorentzVector &p4) const {
0036   return pat::helper::ResolutionHelper::getResolE(parametrization_, covmatrix_, p4);
0037 }
0038 double pat::CandKinResolution::resolEt(const pat::CandKinResolution::LorentzVector &p4) const {
0039   return pat::helper::ResolutionHelper::getResolEt(parametrization_, covmatrix_, p4);
0040 }
0041 double pat::CandKinResolution::resolM(const pat::CandKinResolution::LorentzVector &p4) const {
0042   return pat::helper::ResolutionHelper::getResolM(parametrization_, covmatrix_, p4);
0043 }
0044 double pat::CandKinResolution::resolP(const pat::CandKinResolution::LorentzVector &p4) const {
0045   return pat::helper::ResolutionHelper::getResolP(parametrization_, covmatrix_, p4);
0046 }
0047 double pat::CandKinResolution::resolPt(const pat::CandKinResolution::LorentzVector &p4) const {
0048   return pat::helper::ResolutionHelper::getResolPt(parametrization_, covmatrix_, p4);
0049 }
0050 double pat::CandKinResolution::resolPInv(const pat::CandKinResolution::LorentzVector &p4) const {
0051   return pat::helper::ResolutionHelper::getResolPInv(parametrization_, covmatrix_, p4);
0052 }
0053 double pat::CandKinResolution::resolPx(const pat::CandKinResolution::LorentzVector &p4) const {
0054   return pat::helper::ResolutionHelper::getResolPx(parametrization_, covmatrix_, p4);
0055 }
0056 double pat::CandKinResolution::resolPy(const pat::CandKinResolution::LorentzVector &p4) const {
0057   return pat::helper::ResolutionHelper::getResolPy(parametrization_, covmatrix_, p4);
0058 }
0059 double pat::CandKinResolution::resolPz(const pat::CandKinResolution::LorentzVector &p4) const {
0060   return pat::helper::ResolutionHelper::getResolPz(parametrization_, covmatrix_, p4);
0061 }
0062 
0063 void pat::CandKinResolution::fillVector() {
0064   if (dimension() == 3) {
0065     AlgebraicSymMatrix33 sub = covmatrix_.Sub<AlgebraicSymMatrix33>(0, 0);
0066     covariances_.insert(covariances_.end(), sub.begin(), sub.end());
0067   } else {
0068     covariances_.insert(covariances_.end(), covmatrix_.begin(), covmatrix_.end());
0069   }
0070 }
0071 
0072 void pat::CandKinResolution::fillMatrixFrom(Parametrization parametrization,
0073                                             const std::vector<Scalar> &covariances,
0074                                             AlgebraicSymMatrix44 &covmatrix) {
0075   int dimension = dimensionFrom(parametrization);
0076   if (dimension == 3) {
0077     if (covariances.size() == 3) {
0078       for (int i = 0; i < 3; ++i)
0079         covmatrix(i, i) = covariances[i];
0080     } else {
0081       covmatrix.Place_at(AlgebraicSymMatrix33(covariances.begin(), covariances.end()), 0, 0);
0082     }
0083   } else if (dimension == 4) {
0084     if (covariances.size() == 4) {
0085       for (int i = 0; i < 4; ++i)
0086         covmatrix(i, i) = covariances[i];
0087     } else {
0088       covmatrix = AlgebraicSymMatrix44(covariances.begin(), covariances.end());
0089     }
0090   }
0091 }
0092 
0093 void pat::CandKinResolution::fillMatrix() { fillMatrixFrom(parametrization_, covariances_, covmatrix_); }