Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-06-24 22:38:51

0001 #ifndef DetLayers_DetGroup_h
0002 #define DetLayers_DetGroup_h
0003 
0004 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
0005 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0006 #include <vector>
0007 #include <utility>
0008 #include <algorithm>
0009 
0010 class DetGroupElement {
0011 public:
0012   typedef std::pair<const GeomDet*, TrajectoryStateOnSurface> DetWithState;
0013   typedef GeomDet Det;
0014 
0015   DetGroupElement(const DetWithState& dws) : det_(dws.first), state_(dws.second) {}
0016 
0017   DetGroupElement(const Det* d, const TrajectoryStateOnSurface& s) : det_(d), state_(s) {}
0018 
0019   DetGroupElement(DetGroupElement const& rhs) : det_(rhs.det_), state_(rhs.state_) {}
0020   DetGroupElement(DetGroupElement&& rhs) noexcept : det_(rhs.det_), state_(std::move(rhs.state_)) {}
0021   DetGroupElement& operator=(DetGroupElement const& rhs) {
0022     det_ = rhs.det_;
0023     state_ = rhs.state_;
0024     return *this;
0025   }
0026   DetGroupElement& operator=(DetGroupElement&& rhs) noexcept {
0027     det_ = rhs.det_;
0028     state_ = std::move(rhs.state_);
0029     return *this;
0030   }
0031   DetGroupElement(const Det* d, TrajectoryStateOnSurface&& s) noexcept : det_(d), state_(std::move(s)) {}
0032 
0033   const Det* det() const { return det_; }
0034   const TrajectoryStateOnSurface& trajectoryState() const { return state_; }
0035 
0036 private:
0037   const Det* det_;
0038   TrajectoryStateOnSurface state_;
0039 };
0040 
0041 class DetGroup : public std::vector<DetGroupElement> {
0042 public:
0043   typedef std::vector<DetGroupElement> Base;
0044   typedef DetGroupElement::DetWithState DetWithState;
0045 
0046   DetGroup() : index_(0), indexSize_(0) {}
0047   DetGroup(DetGroup const& rhs) : Base(rhs), index_(rhs.index_), indexSize_(rhs.indexSize_) {}
0048   DetGroup(DetGroup&& rhs) noexcept : Base(std::forward<Base>(rhs)), index_(rhs.index_), indexSize_(rhs.indexSize_) {}
0049   DetGroup& operator=(DetGroup const& rhs) {
0050     Base::operator=(rhs);
0051     index_ = rhs.index_;
0052     indexSize_ = rhs.indexSize_;
0053     return *this;
0054   }
0055   DetGroup& operator=(DetGroup&& rhs) noexcept {
0056     Base::operator=(std::forward<Base>(rhs));
0057     index_ = rhs.index_;
0058     indexSize_ = rhs.indexSize_;
0059     return *this;
0060   }
0061 
0062   DetGroup(int ind, int indSize) : index_(ind), indexSize_(indSize) {}
0063 
0064   DetGroup(const std::vector<DetWithState>& vec) {
0065     reserve(vec.size());
0066     for (std::vector<DetWithState>::const_iterator i = vec.begin(); i != vec.end(); i++) {
0067       push_back(DetGroupElement(*i));
0068     }
0069   }
0070 
0071   int index() const { return index_; }
0072 
0073   int indexSize() const { return indexSize_; }
0074 
0075   void setIndexSize(int newSize) { indexSize_ = newSize; }
0076 
0077   void incrementIndex(int incr) {
0078     // for (iterator i=begin(); i!=end(); i++) i->incrementIndex(incr);
0079     index_ += incr;
0080     indexSize_ += incr;
0081   }
0082 
0083 private:
0084   int index_;
0085   int indexSize_;
0086 };
0087 
0088 #endif