CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTReadoutCollection.h

Go to the documentation of this file.
00001 //---------------------------------------------
00002 //
00003 //   \class L1MuGMTReadoutCollection
00004 //
00005 //   Description: 
00006 //
00007 //
00008 //   $Date: 2011/11/10 17:02:05 $
00009 //   $Revision: 1.6 $
00010 //
00011 //   Author :
00012 //   Hannes Sakulin                  HEPHY Vienna
00013 //   Ivan Mikulec                    HEPHY Vienna
00014 //
00015 //--------------------------------------------------
00016 #ifndef DataFormatsL1GlobalMuonTrigger_L1MuGMTReadoutCollection_h
00017 #define DataFormatsL1GlobalMuonTrigger_L1MuGMTReadoutCollection_h
00018 
00019 //---------------
00020 // C++ Headers --
00021 //---------------
00022 
00023 #include <vector>
00024 #include <map>
00025 #include <iostream>
00026 
00027 //----------------------
00028 // Base Class Headers --
00029 //----------------------
00030 
00031 //------------------------------------
00032 // Collaborating Class Declarations --
00033 //------------------------------------
00034 
00035 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTReadoutRecord.h"
00036 
00037 //---------------------
00038 //-- Class Interface --
00039 //---------------------
00040 
00041 class L1MuGMTReadoutCollection {
00042 
00043  public:
00044 
00045   L1MuGMTReadoutCollection() {};
00046   L1MuGMTReadoutCollection(int nbx) { m_Records.reserve(nbx); };
00047 
00048   virtual ~L1MuGMTReadoutCollection() {};
00049 
00050   void reset() { for(unsigned int i=0; i<m_Records.size(); i++) m_Records[i].reset(); };
00051 
00052   // get record vector
00053   std::vector<L1MuGMTReadoutRecord> const & getRecords() const { return m_Records; };
00054 
00055   // get record for a given bx
00056   L1MuGMTReadoutRecord const & getRecord(int bx=0) const {
00057     std::vector<L1MuGMTReadoutRecord>::const_iterator iter;
00058     for (iter=m_Records.begin(); iter!=m_Records.end(); iter++) {
00059       if ((*iter).getBxCounter() == bx) return (*iter);
00060     }
00061     // if bx not found return empty readout record
00062     static std::map<int, L1MuGMTReadoutRecord> empty_record_cache;
00063     if (empty_record_cache.find(bx) == empty_record_cache.end())
00064       empty_record_cache.insert( std::make_pair(bx, L1MuGMTReadoutRecord(bx)) );
00065     return empty_record_cache[bx];
00066   };
00067 
00068   // add record
00069   void addRecord(L1MuGMTReadoutRecord const& rec) {
00070     m_Records.push_back(rec);
00071   };
00072 
00073  private:
00074 
00075   std::vector<L1MuGMTReadoutRecord> m_Records;
00076 
00077 };
00078 
00079 #endif // DataFormatsL1GlobalMuonTrigger_L1MuGMTReadoutCollection_h