Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:44:36

0001 #include "Alignment/CommonAlignment/interface/AlignmentParametersData.h"
0002 
0003 #include "FWCore/Utilities/interface/Exception.h"
0004 
0005 #include <algorithm>
0006 #include <functional>
0007 
0008 AlignmentParametersData::AlignmentParametersData(void)
0009     : theParameters(new AlgebraicVector()),
0010       theCovariance(new AlgebraicSymMatrix()),
0011       theSelector(new std::vector<bool>()),
0012       theNumSelected(0) {}
0013 
0014 AlignmentParametersData::AlignmentParametersData(AlgebraicVector* param,
0015                                                  AlgebraicSymMatrix* cov,
0016                                                  std::vector<bool>* sel)
0017     : theParameters(param), theCovariance(cov), theSelector(sel) {
0018   theNumSelected = std::count_if(theSelector->begin(), theSelector->end(), [](auto const& c) { return c == true; });
0019 }
0020 
0021 AlignmentParametersData::AlignmentParametersData(const AlgebraicVector& param,
0022                                                  const AlgebraicSymMatrix& cov,
0023                                                  const std::vector<bool>& sel)
0024     : theParameters(new AlgebraicVector(param)),
0025       theCovariance(new AlgebraicSymMatrix(cov)),
0026       theSelector(new std::vector<bool>(sel)) {
0027   theNumSelected = std::count_if(theSelector->begin(), theSelector->end(), [](auto const& c) { return c == true; });
0028 }
0029 
0030 AlignmentParametersData::AlignmentParametersData(AlgebraicVector* param, AlgebraicSymMatrix* cov)
0031     : theParameters(param),
0032       theCovariance(cov),
0033       theSelector(new std::vector<bool>(param->num_row(), true)),
0034       theNumSelected(param->num_row()) {}
0035 
0036 AlignmentParametersData::AlignmentParametersData(const AlgebraicVector& param, const AlgebraicSymMatrix& cov)
0037     : theParameters(new AlgebraicVector(param)),
0038       theCovariance(new AlgebraicSymMatrix(cov)),
0039       theSelector(new std::vector<bool>(param.num_row(), true)),
0040       theNumSelected(param.num_row()) {}
0041 
0042 AlignmentParametersData::~AlignmentParametersData(void) {
0043   delete theParameters;
0044   delete theCovariance;
0045   delete theSelector;
0046 }
0047 
0048 void AlignmentParametersData::checkConsistency(void) const {
0049   int selectorSize = static_cast<int>(theSelector->size());
0050   int paramSize = theParameters->num_row();
0051   int covSize = theCovariance->num_row();
0052 
0053   if ((paramSize != covSize) || (paramSize != selectorSize))
0054     throw cms::Exception("LogicError") << "@SUB=AlignmentParametersData::checkConsistency "
0055                                        << "\nSize mismatch: parameter size = " << paramSize
0056                                        << ", covariance size = " << covSize << ", selector size = " << selectorSize
0057                                        << ".";
0058 }