CMS 3D CMS Logo

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