CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/CondFormats/GeometryObjects/interface/RecoIdealGeometry.h

Go to the documentation of this file.
00001 #ifndef GUARD_RecoIdealGeometry_H
00002 #define GUARD_RecoIdealGeometry_H
00003 
00004 #include <vector>
00005 #include <algorithm>
00006 #include <cassert>
00007 
00008 #include <DataFormats/DetId/interface/DetId.h>
00009 
00026 class RecoIdealGeometry {
00027  public:
00028 
00029   RecoIdealGeometry() { }
00030   ~RecoIdealGeometry() { }
00031 
00032   bool insert( DetId id, const std::vector<double>& trans, const std::vector<double>& rot, const std::vector<double>& pars ) {
00033     if ( trans.size() != 3 || rot.size() != 9 ) return false;
00034     pDetIds.push_back(id);
00035     pNumShapeParms.push_back(pars.size()); // number of shape specific parameters.
00036     pParsIndex.push_back(pPars.size()); // start of this guys "blob"
00037     pPars.reserve(pPars.size() + trans.size() + rot.size() + pars.size());
00038     std::copy ( trans.begin(), trans.end(), std::back_inserter(pPars));
00039     std::copy ( rot.begin(), rot.end(), std::back_inserter(pPars));
00040     std::copy ( pars.begin(), pars.end(), std::back_inserter(pPars));
00041     return true;
00042   }
00043 
00044   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 ) {
00045     if ( trans.size() != 3 || rot.size() != 9 ) return false;
00046     pDetIds.push_back(id);
00047     pNumShapeParms.push_back(pars.size()); // number of shape specific parameters.
00048     pParsIndex.push_back(pPars.size()); // start of this guys "blob"
00049     pPars.reserve(pPars.size() + trans.size() + rot.size() + pars.size());
00050     std::copy ( trans.begin(), trans.end(), std::back_inserter(pPars));
00051     std::copy ( rot.begin(), rot.end(), std::back_inserter(pPars));
00052     std::copy ( pars.begin(), pars.end(), std::back_inserter(pPars));
00053 
00054     sNumsParms.push_back(spars.size());
00055     sParsIndex.push_back(strPars.size());
00056     strPars.reserve(strPars.size()+spars.size());
00057     std::copy ( spars.begin(), spars.end(), std::back_inserter(strPars));
00058     return true;
00059   }
00060 
00061   size_t size() { 
00062     assert ( (pDetIds.size() == pNumShapeParms.size()) && (pNumShapeParms.size() == pParsIndex.size()) );
00063     return pDetIds.size(); 
00064   }
00065 
00066   // HOW to use this stuff... first, get hold of the reference to the detIds like:
00067   // const std::vector<double>& myds = classofthistype.detIds()
00068   // Then iterate over the detIds using 
00069   // for ( size_t it = 0 ; it < myds.size(); ++it ) 
00070   // and ask for the parts ...
00071   // {
00072   //   std::vector<double>::const_iterator xyzB = classofthistype.transStart(it);
00073   //   std::vector<double>::const_iterator xyzE = classofthistype.transEnd(it);
00074   // }
00075   const std::vector<DetId>& detIds () const {
00076     return pDetIds;
00077   }
00078 
00079   std::vector<double>::const_iterator tranStart( size_t ind ) const { 
00080      return pPars.begin() + pParsIndex[ind]; 
00081   }
00082 
00083   std::vector<double>::const_iterator tranEnd ( size_t ind ) const { 
00084      return pPars.begin() + pParsIndex[ind] + 3; 
00085   }
00086 
00087   std::vector<double>::const_iterator rotStart ( size_t ind ) const {
00088     return pPars.begin() + pParsIndex[ind] + 3;
00089   }
00090 
00091   std::vector<double>::const_iterator rotEnd ( size_t ind ) const {
00092     return pPars.begin() + pParsIndex[ind] + 3 + 9;
00093   }
00094 
00095   std::vector<double>::const_iterator shapeStart ( size_t ind ) const {
00096     return pPars.begin() + pParsIndex[ind] + 3 + 9;
00097   }
00098 
00099   std::vector<double>::const_iterator shapeEnd ( size_t ind ) const {
00100     return pPars.begin() + pParsIndex[ind] + 3 + 9 + pNumShapeParms[ind];
00101   }
00102 
00103   std::vector<std::string>::const_iterator strStart ( size_t ind ) const {
00104     return strPars.begin() + sParsIndex[ind];
00105   }
00106 
00107   std::vector<std::string>::const_iterator strEnd ( size_t ind ) const {
00108     return strPars.begin() + sParsIndex[ind] + sNumsParms[ind];
00109   }
00110 
00111 
00112  private:    
00113   // translation always 3; rotation 9 for now; pars depends on shape_type.
00114   std::vector<DetId> pDetIds;
00115 
00116   std::vector<double> pPars;  // trans, rot then shape parms.
00117   // 0 for first pDetId, 3 + 9 + number of shape parameters for second & etc.
00118   // just save pPars size BEFORE adding next stuff.
00119   std::vector<int> pParsIndex; 
00120   std::vector<int> pNumShapeParms; // save the number of shape parameters.
00121 
00122   std::vector<std::string> strPars;
00123   std::vector<int> sParsIndex;
00124   std::vector<int> sNumsParms;
00125 };
00126 
00127 #endif
00128