CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/CondFormats/RPCObjects/interface/L1RPCHwConfig.h

Go to the documentation of this file.
00001 #ifndef CondFormats_RPCObjects_L1RPCHwConfig_h
00002 #define CondFormats_RPCObjects_L1RPCHwConfig_h
00003 // -*- C++ -*-
00004 //
00005 // Package:     RPCObjects
00006 // Class  :     L1RPCHwConfig
00007 // 
00016 //
00017 // Original Author:  
00018 //         Created:  Wed Apr  9 13:48:06 CEST 2008
00019 // $Id: L1RPCHwConfig.h,v 1.5 2010/02/26 15:50:38 fruboes Exp $
00020 //
00021 
00022 // system include files
00023 
00024 // user include files
00025 
00026 // forward declarations
00027 #include <set>
00028 #include <vector>
00029 #include <sstream>
00030 
00031 #include <iostream>
00032 
00033 struct L1RPCDevCoords {
00034  public:
00035   L1RPCDevCoords(): m_tower(-255), m_PAC(-255) {};
00036   L1RPCDevCoords(int tower, int sector, int segment): m_tower(tower), m_PAC(sector*12+segment) {};
00037   int getTower() {return m_tower;};
00038   int getPAC() {return m_PAC;};
00039   int getSector() {return m_PAC/12;};
00040   int getSegment() {return m_PAC%12;};
00041 
00042   std::string toString() const { 
00043       std::stringstream ss;
00044       ss << m_tower << " " << m_PAC;  
00045       return ss.str();
00046   };
00047 
00048   bool operator<(const L1RPCDevCoords & l2 ) const{
00049     if (this->m_tower != l2.m_tower)
00050        return this->m_tower < l2.m_tower;
00051     return this->m_PAC < l2.m_PAC;
00052   }
00053 
00054   bool operator==(const L1RPCDevCoords & l2) const{
00055     return (this->m_tower == l2.m_tower) && (this->m_PAC == l2.m_PAC);
00056   }
00057  
00058 
00059  //private:
00060    signed short m_tower;
00061    signed short m_PAC;
00062 
00063 };
00064 
00065 
00066 class L1RPCHwConfig
00067 {
00068 
00069    public:
00070       L1RPCHwConfig();
00071       virtual ~L1RPCHwConfig();
00072 
00073 
00074       
00075       bool isActive(int tower, int sector, int segment) const
00076            {
00077              return m_disabledDevices.find( L1RPCDevCoords(tower, sector, segment) )==m_disabledDevices.end(); 
00078            };
00079 
00080       bool isActive(int tower, int PAC) const
00081            {
00082              return m_disabledDevices.end()==m_disabledDevices.find( L1RPCDevCoords(tower, PAC/12, PAC%12) ); 
00083            };
00084 
00085       void enablePAC(int tower, int sector, int segment, bool enable);
00086 
00087       void enableTower(int tower, bool enable);
00088 
00089       void enableTowerInCrate(int tower, int crate, bool enable);
00090 
00091       void enableCrate(int logSector, bool enable); // logSector == crate number /// enables one crate, all towers
00092 
00093       void enableAll(bool enable);
00094 
00095       int size() const {return m_disabledDevices.size(); } ;
00096       void dump() const {
00097          for(std::set<L1RPCDevCoords>::const_iterator it=m_disabledDevices.begin(); it!=m_disabledDevices.end();++it){
00098            std::cout << it->toString() << std::endl;
00099          }
00100       };
00101 
00102       // ---------- const member functions ---------------------
00103 
00104       // ---------- static member functions --------------------
00105 
00106       // ---------- member functions ---------------------------
00107 
00108 
00109    private:
00110 
00111       std::set<L1RPCDevCoords> m_disabledDevices;
00112 
00113       // ---------- member data --------------------------------
00114 
00115 };
00116 
00117 
00118 #endif