Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:55

0001 #ifndef AlignmentSurfaceDeformations_H
0002 #define AlignmentSurfaceDeformations_H
0003 
0004 #include "CondFormats/Serialization/interface/Serializable.h"
0005 
0006 #include <vector>
0007 
0008 #include "CondFormats/Alignment/interface/Definitions.h"
0009 
0010 /// \class AlignmentSurfaceDeformations
0011 ///
0012 /// Class for DB storage of surface deformation parameters. The actual
0013 /// parameters for all detector IDs are stored inside one big vector.
0014 /// Access is provided via a pair of iterators for this vector.
0015 ///
0016 ///  $Date: 2010/10/26 20:41:07 $
0017 ///  $Revision: 1.1 $
0018 /// (last update by $Author: flucke $)
0019 
0020 class AlignmentSurfaceDeformations {
0021 public:
0022   struct Item {
0023     align::ID m_rawId;
0024     int m_parametrizationType;
0025     int m_index;
0026 
0027     COND_SERIALIZABLE;
0028   };
0029 
0030   typedef std::vector<Item> ItemVector;
0031   typedef std::vector<align::Scalar>::const_iterator ParametersConstIterator;
0032   typedef std::pair<ParametersConstIterator, ParametersConstIterator> ParametersConstIteratorPair;
0033 
0034   AlignmentSurfaceDeformations() {}
0035   virtual ~AlignmentSurfaceDeformations() {}
0036 
0037   /// Test of empty vector without having to look into internals:
0038   inline bool empty() const { return m_items.empty(); }
0039 
0040   /// Add a new item
0041   bool add(align::ID rawId, int type, const std::vector<align::Scalar>& parameters) {
0042     Item item;
0043     item.m_rawId = rawId;
0044     item.m_parametrizationType = type;
0045     item.m_index = m_parameters.size();
0046     m_items.push_back(item);
0047 
0048     m_parameters.reserve(m_parameters.size() + parameters.size());
0049     std::copy(parameters.begin(), parameters.end(), std::back_inserter(m_parameters));
0050 
0051     return true;
0052   }
0053 
0054   /// Get vector of all items
0055   const ItemVector& items() const { return m_items; }
0056 
0057   /// Get a pair of iterators for the item at given index. The iterators can
0058   /// be used to access the actual parameters for that item
0059   ParametersConstIteratorPair parameters(size_t index) const {
0060     ParametersConstIteratorPair pair;
0061     pair.first = m_parameters.begin() + m_items[index].m_index;
0062     if (index < m_items.size() - 1) {
0063       pair.second = m_parameters.begin() + m_items[index + 1].m_index;
0064     } else {
0065       pair.second = m_parameters.end();
0066     }
0067     return pair;
0068   }
0069 
0070 private:
0071   std::vector<align::Scalar> m_parameters;
0072   ItemVector m_items;
0073 
0074   COND_SERIALIZABLE;
0075 };
0076 
0077 #endif  // AlignmentSurfaceDeformations_H