File indexing completed on 2024-04-06 12:02:12
0001 #ifndef GUARD_RecoIdealGeometry_H
0002 #define GUARD_RecoIdealGeometry_H
0003
0004 #include "CondFormats/Serialization/interface/Serializable.h"
0005
0006 #include <vector>
0007 #include <algorithm>
0008 #include <cassert>
0009
0010 #include <DataFormats/DetId/interface/DetId.h>
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 class RecoIdealGeometry {
0029 public:
0030 RecoIdealGeometry() {}
0031 ~RecoIdealGeometry() {}
0032
0033 bool insert(DetId id,
0034 const std::vector<double>& trans,
0035 const std::vector<double>& rot,
0036 const std::vector<double>& pars) {
0037 if (trans.size() != 3 || rot.size() != 9)
0038 return false;
0039 pDetIds.push_back(id);
0040 pNumShapeParms.push_back(pars.size());
0041 pParsIndex.push_back(pPars.size());
0042 pPars.reserve(pPars.size() + trans.size() + rot.size() + pars.size());
0043 std::copy(trans.begin(), trans.end(), std::back_inserter(pPars));
0044 std::copy(rot.begin(), rot.end(), std::back_inserter(pPars));
0045 std::copy(pars.begin(), pars.end(), std::back_inserter(pPars));
0046 return true;
0047 }
0048
0049 bool insert(DetId id,
0050 const std::vector<double>& trans,
0051 const std::vector<double>& rot,
0052 const std::vector<double>& pars,
0053 const std::vector<std::string>& spars) {
0054 if (trans.size() != 3 || rot.size() != 9)
0055 return false;
0056 pDetIds.push_back(id);
0057 pNumShapeParms.push_back(pars.size());
0058 pParsIndex.push_back(pPars.size());
0059 pPars.reserve(pPars.size() + trans.size() + rot.size() + pars.size());
0060 std::copy(trans.begin(), trans.end(), std::back_inserter(pPars));
0061 std::copy(rot.begin(), rot.end(), std::back_inserter(pPars));
0062 std::copy(pars.begin(), pars.end(), std::back_inserter(pPars));
0063
0064 sNumsParms.push_back(spars.size());
0065 sParsIndex.push_back(strPars.size());
0066 strPars.reserve(strPars.size() + spars.size());
0067 std::copy(spars.begin(), spars.end(), std::back_inserter(strPars));
0068 return true;
0069 }
0070
0071 size_t size() {
0072 assert((pDetIds.size() == pNumShapeParms.size()) && (pNumShapeParms.size() == pParsIndex.size()));
0073 return pDetIds.size();
0074 }
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085 const std::vector<DetId>& detIds() const { return pDetIds; }
0086
0087 std::vector<double>::const_iterator tranStart(size_t ind) const { return pPars.begin() + pParsIndex[ind]; }
0088
0089 std::vector<double>::const_iterator tranEnd(size_t ind) const { return pPars.begin() + pParsIndex[ind] + 3; }
0090
0091 std::vector<double>::const_iterator rotStart(size_t ind) const { return pPars.begin() + pParsIndex[ind] + 3; }
0092
0093 std::vector<double>::const_iterator rotEnd(size_t ind) const { return pPars.begin() + pParsIndex[ind] + 3 + 9; }
0094
0095 std::vector<double>::const_iterator shapeStart(size_t ind) const { return pPars.begin() + pParsIndex[ind] + 3 + 9; }
0096
0097 std::vector<double>::const_iterator shapeEnd(size_t ind) const {
0098 return pPars.begin() + pParsIndex[ind] + 3 + 9 + pNumShapeParms[ind];
0099 }
0100
0101 std::vector<std::string>::const_iterator strStart(size_t ind) const { return strPars.begin() + sParsIndex[ind]; }
0102
0103 std::vector<std::string>::const_iterator strEnd(size_t ind) const {
0104 return strPars.begin() + sParsIndex[ind] + sNumsParms[ind];
0105 }
0106
0107 private:
0108
0109 std::vector<DetId> pDetIds;
0110
0111 std::vector<double> pPars;
0112
0113
0114 std::vector<int> pParsIndex;
0115 std::vector<int> pNumShapeParms;
0116
0117 std::vector<std::string> strPars;
0118 std::vector<int> sParsIndex;
0119 std::vector<int> sNumsParms;
0120
0121 COND_SERIALIZABLE;
0122 };
0123
0124 #endif