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