CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/DataFormats/L1CSCTrackFinder/interface/CSCTriggerContainer.h

Go to the documentation of this file.
00001 #ifndef CSCCommonTrigger_CSCTriggerContainer_h
00002 #define CSCCommonTrigger_CSCTriggerContainer_h
00003 
00020 #include <vector>
00021 
00022 template<class T>
00023 class CSCTriggerContainer
00024 {
00025  public:
00026 
00027   CSCTriggerContainer() {}
00028   CSCTriggerContainer(const CSCTriggerContainer& cpy) { _objs = cpy._objs; }
00029   CSCTriggerContainer(const std::vector<T>&);
00030 
00031   CSCTriggerContainer& operator=(const CSCTriggerContainer&);
00032   CSCTriggerContainer& operator=(const std::vector<T>&);
00033 
00034   std::vector<T> get() const;
00035   std::vector<T> get(const unsigned& endcap, const unsigned& station, const unsigned& tsector, 
00036                      const unsigned& tsubsector, const unsigned& cscid, const int& BX) const; 
00037 
00038   std::vector<T> get(const unsigned& endcap, const unsigned& station, const unsigned& tsector,    
00039                      const unsigned& tsubsector, const int& BX) const;
00040   std::vector<T> get(const unsigned& endcap, const unsigned& sector, const int& BX) const; 
00041   std::vector<T> get(const unsigned& endcap, const unsigned& sector) const;
00042   std::vector<T> get(const int& BX) const;
00043 
00044   void push_back(const T data) { _objs.push_back(data); }
00045   void push_many(const std::vector<T> data) { _objs.insert(_objs.end(), data.begin(), data.end()); }
00046   void push_many(const CSCTriggerContainer<T> data) { std::vector<T> vec = data.get(); _objs.insert(_objs.end(), vec.begin(), vec.end()); }
00047   void clear() { _objs.clear(); } 
00048 
00049  private:
00050   
00051   std::vector<T> _objs;
00052 };
00053 
00054 template<class T>
00055 CSCTriggerContainer<T>::CSCTriggerContainer(const std::vector<T>& parent)
00056 {
00057   _objs = parent;
00058 }
00059 
00060 template<class T>
00061 CSCTriggerContainer<T>& CSCTriggerContainer<T>::operator=(const CSCTriggerContainer& rhs)
00062 {
00063   if(this != &rhs)
00064     {
00065       _objs = rhs._objs;
00066     }
00067   return *this;
00068 }
00069 
00070 template<class T>
00071 CSCTriggerContainer<T>& CSCTriggerContainer<T>::operator=(const std::vector<T>& rhs)
00072 {
00073   _objs = rhs;
00074   return *this;
00075 }
00076 
00077 template<class T>
00078 std::vector<T> CSCTriggerContainer<T>::get() const
00079 {
00080   return _objs;
00081 }
00082 
00083 template<class T>
00084 std::vector<T> CSCTriggerContainer<T>::get(const unsigned& endcap, const unsigned& station, 
00085                                            const unsigned& tsector,const unsigned& tsubsector, 
00086                                            const unsigned& cscid, const int& BX) const
00087 {
00088   std::vector<T> result;  
00089 
00090   for(unsigned i = 0; i < _objs.size(); i++)
00091     if(_objs[i].endcap() == endcap && _objs[i].station() == station && 
00092        _objs[i].sector() == tsector && (station != 1 || _objs[i].subsector() == tsubsector) && 
00093        _objs[i].cscid() == cscid && _objs[i].BX() == BX)
00094       result.push_back(_objs[i]);
00095   
00096   return result;
00097 }
00098 
00099 template<class T>
00100 std::vector<T> CSCTriggerContainer<T>::get(const unsigned& endcap, const unsigned& station, 
00101                                            const unsigned& tsector,const unsigned& tsubsector, 
00102                                            const int& BX) const
00103 {
00104   std::vector<T> result;  
00105 
00106   for(unsigned i = 0; i < _objs.size(); ++i)
00107     if(_objs[i].endcap() == endcap && _objs[i].station() == station && 
00108        _objs[i].sector() == tsector && (station != 1 || _objs[i].subsector() == tsubsector) 
00109        && _objs[i].BX() == BX)
00110       result.push_back(_objs[i]);
00111   
00112   return result;
00113 }
00114 
00115 template<class T>
00116 std::vector<T> CSCTriggerContainer<T>::get(const unsigned& endcap, const unsigned& sector, 
00117                                            const int& BX) const
00118 {
00119   std::vector<T> result;
00120 
00121   for(unsigned i = 0; i < _objs.size(); ++i)
00122     if(_objs[i].endcap() == endcap && _objs[i].sector() == sector && _objs[i].BX() == BX)
00123       result.push_back(_objs[i]);
00124 
00125   return result;
00126 }
00127 
00128 template<class T>
00129 std::vector<T> CSCTriggerContainer<T>::get(const unsigned& endcap, const unsigned& sector) const
00130 {
00131   std::vector<T> result;
00132 
00133   for(unsigned i = 0; i < _objs.size(); ++i)
00134     if(_objs[i].endcap() == endcap && _objs[i].sector() == sector)
00135       result.push_back(_objs[i]);
00136 
00137   return result;
00138 }
00139 
00140 template<class T>
00141 std::vector<T> CSCTriggerContainer<T>::get(const int& BX) const
00142 {
00143   std::vector<T> result;
00144 
00145   for(unsigned i = 0; i < _objs.size(); ++i)
00146     if(_objs[i].BX() == BX) result.push_back(_objs[i]);
00147 
00148   return result;
00149 }
00150 
00151 #endif