CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/TrackingTools/DetLayers/interface/DetGroup.h

Go to the documentation of this file.
00001 #ifndef DetLayers_DetGroup_h
00002 #define DetLayers_DetGroup_h 
00003 
00004 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
00005 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
00006 #include <vector>
00007 #include <utility>
00008 #include <algorithm>
00009 
00010 class DetGroupElement {
00011  public:
00012   typedef std::pair<const GeomDet*,TrajectoryStateOnSurface> DetWithState;
00013   typedef GeomDet                                            Det;
00014 
00015  
00016   DetGroupElement( const DetWithState& dws) :
00017     det_(dws.first), state_(dws.second) {}
00018 
00019   DetGroupElement( const Det* d, const TrajectoryStateOnSurface& s) :
00020     det_(d), state_(s) {}
00021 
00022 #if defined( __GXX_EXPERIMENTAL_CXX0X__)
00023   DetGroupElement(DetGroupElement const & rhs) : det_(rhs.det_), state_(rhs.state_){}
00024   DetGroupElement(DetGroupElement && rhs)  noexcept : det_(rhs.det_), state_(std::move(rhs.state_)){}
00025   DetGroupElement & operator=(DetGroupElement const & rhs) {
00026      det_=rhs.det_;
00027      state_ = rhs.state_;
00028      return *this;
00029   }
00030   DetGroupElement & operator=(DetGroupElement && rhs)  noexcept {
00031      det_=rhs.det_;
00032      state_ = std::move(rhs.state_);
00033      return *this;
00034   }
00035 #endif
00036 
00037   const Det* det() const {return det_;}
00038   const TrajectoryStateOnSurface& trajectoryState() const {return state_;}
00039 
00040 private:
00041 
00042   const Det* det_;
00043   TrajectoryStateOnSurface state_;
00044 
00045 };
00046 
00047 
00048 class DetGroup : public std::vector< DetGroupElement> {
00049 public:
00050 
00051   typedef std::vector< DetGroupElement>         Base;
00052   typedef DetGroupElement::DetWithState         DetWithState;
00053 
00054   DetGroup() {}
00055 #if defined( __GXX_EXPERIMENTAL_CXX0X__)
00056   DetGroup(DetGroup const & rhs) : Base(rhs), index_(rhs.index_), indexSize_(rhs.indexSize_)  {}
00057   DetGroup(DetGroup && rhs)  noexcept : Base(std::forward<Base>(rhs)), index_(rhs.index_), indexSize_(rhs.indexSize_)  {}
00058   DetGroup & operator=(DetGroup const & rhs) {
00059     Base::operator=(rhs);
00060     index_ =  rhs.index_;
00061     indexSize_ = rhs.indexSize_;
00062     return *this;
00063   }
00064   DetGroup & operator=(DetGroup && rhs) noexcept { 
00065     Base::operator=(std::forward<Base>(rhs)); 
00066     index_ =  rhs.index_;
00067     indexSize_ = rhs.indexSize_;
00068     return *this;
00069   }
00070 #endif
00071 
00072 
00073   DetGroup(int ind, int indSize) : index_(ind), indexSize_(indSize) {}
00074 
00075   DetGroup(const std::vector<DetWithState>& vec) {
00076     reserve( vec.size());
00077     for (std::vector<DetWithState>::const_iterator i=vec.begin(); i!=vec.end(); i++) {
00078       push_back(DetGroupElement(*i));
00079     }
00080   }
00081 
00082   int index() const {return index_;}
00083 
00084   int indexSize() const {return indexSize_;}
00085 
00086   void setIndexSize( int newSize) {indexSize_ = newSize;}
00087 
00088   void incrementIndex( int incr) {
00089     // for (iterator i=begin(); i!=end(); i++) i->incrementIndex(incr);
00090     index_ += incr;
00091     indexSize_ += incr;
00092   }
00093 
00094 private:
00095 
00096   int index_;
00097   int indexSize_;
00098 
00099 };
00100 
00101 #endif