CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/CondFormats/Alignment/interface/AlignmentSurfaceDeformations.h

Go to the documentation of this file.
00001 #ifndef AlignmentSurfaceDeformations_H
00002 #define AlignmentSurfaceDeformations_H
00003 
00004 #include <vector>
00005 
00006 #include "CondFormats/Alignment/interface/Definitions.h"
00007 
00017 
00018 class AlignmentSurfaceDeformations {
00019 public:
00020 
00021   struct Item {
00022     align::ID m_rawId;
00023     int m_parametrizationType;
00024     int m_index;
00025   };
00026   
00027   typedef std::vector<Item> ItemVector;
00028   typedef std::vector<align::Scalar>::const_iterator ParametersConstIterator;
00029   typedef std::pair<ParametersConstIterator,ParametersConstIterator> ParametersConstIteratorPair;
00030 
00031   AlignmentSurfaceDeformations() { }
00032   virtual ~AlignmentSurfaceDeformations() { }
00033   
00035   inline bool empty() const { return m_items.empty(); }
00036   
00038   bool add(align::ID rawId, int type, const std::vector<align::Scalar> & parameters) {
00039 
00040     Item item;
00041     item.m_rawId = rawId;
00042     item.m_parametrizationType = type;
00043     item.m_index = m_parameters.size();
00044     m_items.push_back(item);
00045 
00046     m_parameters.reserve(m_parameters.size() + parameters.size());
00047     std::copy(parameters.begin(), parameters.end(), std::back_inserter(m_parameters));
00048 
00049     return true;
00050   }
00051 
00053   const ItemVector & items() const {return m_items; }
00054 
00057   ParametersConstIteratorPair parameters( size_t index ) const {
00058     ParametersConstIteratorPair pair;
00059     pair.first  = m_parameters.begin() + m_items[index].m_index;
00060     if (index<m_items.size()-1) {
00061       pair.second = m_parameters.begin() + m_items[index+1].m_index;
00062     } else {
00063       pair.second = m_parameters.end();
00064     }
00065     return pair;
00066   }
00067   
00068  private:
00069 
00070   std::vector<align::Scalar> m_parameters;
00071   ItemVector m_items;
00072 };
00073 
00074 #endif // AlignmentSurfaceDeformations_H