CMS 3D CMS Logo

RecoIdealGeometry.h
Go to the documentation of this file.
1 #ifndef GUARD_RecoIdealGeometry_H
2 #define GUARD_RecoIdealGeometry_H
3 
5 
6 #include <vector>
7 #include <algorithm>
8 #include <cassert>
9 
11 
29 public:
32 
33  bool insert(DetId id,
34  const std::vector<double>& trans,
35  const std::vector<double>& rot,
36  const std::vector<double>& pars) {
37  if (trans.size() != 3 || rot.size() != 9)
38  return false;
39  pDetIds.push_back(id);
40  pNumShapeParms.push_back(pars.size()); // number of shape specific parameters.
41  pParsIndex.push_back(pPars.size()); // start of this guys "blob"
42  pPars.reserve(pPars.size() + trans.size() + rot.size() + pars.size());
43  std::copy(trans.begin(), trans.end(), std::back_inserter(pPars));
44  std::copy(rot.begin(), rot.end(), std::back_inserter(pPars));
45  std::copy(pars.begin(), pars.end(), std::back_inserter(pPars));
46  return true;
47  }
48 
49  bool insert(DetId id,
50  const std::vector<double>& trans,
51  const std::vector<double>& rot,
52  const std::vector<double>& pars,
53  const std::vector<std::string>& spars) {
54  if (trans.size() != 3 || rot.size() != 9)
55  return false;
56  pDetIds.push_back(id);
57  pNumShapeParms.push_back(pars.size()); // number of shape specific parameters.
58  pParsIndex.push_back(pPars.size()); // start of this guys "blob"
59  pPars.reserve(pPars.size() + trans.size() + rot.size() + pars.size());
60  std::copy(trans.begin(), trans.end(), std::back_inserter(pPars));
61  std::copy(rot.begin(), rot.end(), std::back_inserter(pPars));
62  std::copy(pars.begin(), pars.end(), std::back_inserter(pPars));
63 
64  sNumsParms.push_back(spars.size());
65  sParsIndex.push_back(strPars.size());
66  strPars.reserve(strPars.size() + spars.size());
67  std::copy(spars.begin(), spars.end(), std::back_inserter(strPars));
68  return true;
69  }
70 
71  size_t size() {
72  assert((pDetIds.size() == pNumShapeParms.size()) && (pNumShapeParms.size() == pParsIndex.size()));
73  return pDetIds.size();
74  }
75 
76  // HOW to use this stuff... first, get hold of the reference to the detIds like:
77  // const std::vector<double>& myds = classofthistype.detIds()
78  // Then iterate over the detIds using
79  // for ( size_t it = 0 ; it < myds.size(); ++it )
80  // and ask for the parts ...
81  // {
82  // std::vector<double>::const_iterator xyzB = classofthistype.transStart(it);
83  // std::vector<double>::const_iterator xyzE = classofthistype.transEnd(it);
84  // }
85  const std::vector<DetId>& detIds() const { return pDetIds; }
86 
87  std::vector<double>::const_iterator tranStart(size_t ind) const { return pPars.begin() + pParsIndex[ind]; }
88 
89  std::vector<double>::const_iterator tranEnd(size_t ind) const { return pPars.begin() + pParsIndex[ind] + 3; }
90 
91  std::vector<double>::const_iterator rotStart(size_t ind) const { return pPars.begin() + pParsIndex[ind] + 3; }
92 
93  std::vector<double>::const_iterator rotEnd(size_t ind) const { return pPars.begin() + pParsIndex[ind] + 3 + 9; }
94 
95  std::vector<double>::const_iterator shapeStart(size_t ind) const { return pPars.begin() + pParsIndex[ind] + 3 + 9; }
96 
97  std::vector<double>::const_iterator shapeEnd(size_t ind) const {
98  return pPars.begin() + pParsIndex[ind] + 3 + 9 + pNumShapeParms[ind];
99  }
100 
101  std::vector<std::string>::const_iterator strStart(size_t ind) const { return strPars.begin() + sParsIndex[ind]; }
102 
103  std::vector<std::string>::const_iterator strEnd(size_t ind) const {
104  return strPars.begin() + sParsIndex[ind] + sNumsParms[ind];
105  }
106 
107 private:
108  // translation always 3; rotation 9 for now; pars depends on shape_type.
109  std::vector<DetId> pDetIds;
110 
111  std::vector<double> pPars; // trans, rot then shape parms.
112  // 0 for first pDetId, 3 + 9 + number of shape parameters for second & etc.
113  // just save pPars size BEFORE adding next stuff.
114  std::vector<int> pParsIndex;
115  std::vector<int> pNumShapeParms; // save the number of shape parameters.
116 
117  std::vector<std::string> strPars;
118  std::vector<int> sParsIndex;
119  std::vector<int> sNumsParms;
120 
122 };
123 
124 #endif
std::vector< std::string >::const_iterator strStart(size_t ind) const
std::vector< double >::const_iterator shapeEnd(size_t ind) const
std::vector< int > pNumShapeParms
std::vector< std::string >::const_iterator strEnd(size_t ind) const
std::vector< double >::const_iterator rotStart(size_t ind) const
bool insert(DetId id, const std::vector< double > &trans, const std::vector< double > &rot, const std::vector< double > &pars)
std::vector< DetId > pDetIds
assert(be >=bs)
std::vector< double >::const_iterator tranEnd(size_t ind) const
std::vector< int > pParsIndex
std::vector< int > sNumsParms
const std::vector< DetId > & detIds() const
bool insert(DetId id, const std::vector< double > &trans, const std::vector< double > &rot, const std::vector< double > &pars, const std::vector< std::string > &spars)
std::vector< double > pPars
Definition: DetId.h:17
std::vector< double >::const_iterator shapeStart(size_t ind) const
std::vector< std::string > strPars
#define COND_SERIALIZABLE
Definition: Serializable.h:39
std::vector< int > sParsIndex
std::vector< double >::const_iterator rotEnd(size_t ind) const
std::vector< double >::const_iterator tranStart(size_t ind) const