Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:51:27

0001 #ifndef CondFormats_RPCObjects_L1RPCHwConfig_h
0002 #define CondFormats_RPCObjects_L1RPCHwConfig_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     RPCObjects
0006 // Class  :     L1RPCHwConfig
0007 //
0008 /**\class L1RPCHwConfig L1RPCHwConfig.h CondFormats/RPCObjects/interface/L1RPCHwConfig.h
0009 
0010  Description: Contains multiple BX triggering info. Also info about disabled devices
0011 
0012  Usage:
0013     <usage>
0014 
0015 */
0016 //
0017 // Original Author:
0018 //         Created:  Wed Apr  9 13:48:06 CEST 2008
0019 // $Id: L1RPCHwConfig.h,v 1.4 2008/06/24 11:06:53 michals Exp $
0020 //
0021 
0022 // system include files
0023 
0024 // user include files
0025 
0026 // forward declarations
0027 #include "CondFormats/Serialization/interface/Serializable.h"
0028 
0029 #include <set>
0030 #include <vector>
0031 #include <sstream>
0032 
0033 #include <iostream>
0034 
0035 struct L1RPCDevCoords {
0036 public:
0037   L1RPCDevCoords() : m_tower(-255), m_PAC(-255){};
0038   L1RPCDevCoords(int tower, int sector, int segment) : m_tower(tower), m_PAC(sector * 12 + segment){};
0039   int getTower() { return m_tower; };
0040   int getPAC() { return m_PAC; };
0041   int getSector() { return m_PAC / 12; };
0042   int getSegment() { return m_PAC % 12; };
0043 
0044   std::string toString() const {
0045     std::stringstream ss;
0046     ss << m_tower << " " << m_PAC;
0047     return ss.str();
0048   };
0049 
0050   bool operator<(const L1RPCDevCoords& l2) const {
0051     if (this->m_tower != l2.m_tower)
0052       return this->m_tower < l2.m_tower;
0053     return this->m_PAC < l2.m_PAC;
0054   }
0055 
0056   bool operator==(const L1RPCDevCoords& l2) const { return (this->m_tower == l2.m_tower) && (this->m_PAC == l2.m_PAC); }
0057 
0058   //private:
0059   signed short m_tower;
0060   signed short m_PAC;
0061 
0062   COND_SERIALIZABLE;
0063 };
0064 
0065 class L1RPCHwConfig {
0066 public:
0067   L1RPCHwConfig();
0068   virtual ~L1RPCHwConfig();
0069 
0070   bool isActive(int tower, int sector, int segment) const {
0071     return m_disabledDevices.find(L1RPCDevCoords(tower, sector, segment)) == m_disabledDevices.end();
0072   };
0073 
0074   bool isActive(int tower, int PAC) const {
0075     return m_disabledDevices.end() == m_disabledDevices.find(L1RPCDevCoords(tower, PAC / 12, PAC % 12));
0076   };
0077 
0078   void enablePAC(int tower, int sector, int segment, bool enable);
0079 
0080   void enableTower(int tower, bool enable);
0081 
0082   void enableTowerInCrate(int tower, int crate, bool enable);
0083 
0084   void enableCrate(int logSector, bool enable);  // logSector == crate number /// enables one crate, all towers
0085 
0086   void enableAll(bool enable);
0087 
0088   int size() const { return m_disabledDevices.size(); };
0089   void dump() const {
0090     for (std::set<L1RPCDevCoords>::const_iterator it = m_disabledDevices.begin(); it != m_disabledDevices.end(); ++it) {
0091       std::cout << it->toString() << std::endl;
0092     }
0093   };
0094 
0095   // ---------- const member functions ---------------------
0096 
0097   // ---------- static member functions --------------------
0098 
0099   // ---------- member functions ---------------------------
0100 
0101 private:
0102   std::set<L1RPCDevCoords> m_disabledDevices;
0103 
0104   // ---------- member data --------------------------------
0105 
0106   COND_SERIALIZABLE;
0107 };
0108 
0109 #endif