Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:59

0001 /*
0002  * =====================================================================================
0003  *
0004  *       Filename:  CSCDQM_DCSBase.h
0005  *
0006  *    Description:  CSCDQM DCS Base Objects
0007  *
0008  *        Version:  1.0
0009  *        Created:  05/04/2009 11:10:14 AM
0010  *       Revision:  none
0011  *       Compiler:  gcc
0012  *
0013  *         Author:  Valdas Rapsevicius (VR), valdas.rapsevicius@cern.ch
0014  *        Company:  CERN, CH
0015  *
0016  * =====================================================================================
0017  */
0018 
0019 #ifndef CSCDQM_DCSBASE_H
0020 #define CSCDQM_DCSBASE_H
0021 
0022 #include "CondFormats/Serialization/interface/Serializable.h"
0023 
0024 #include <iostream>
0025 #include <sstream>
0026 
0027 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0028 
0029 namespace cscdqm {
0030 
0031   /** Type to store Unix timetamp */
0032   typedef long long TimeType;
0033 
0034   /** Enumeration of Board Types */
0035   enum DCSBoardType { ANY = 0, ALCT = 1, CFEB = 2, DMB = 3 };
0036 
0037   /** DCSBoardType utility object type */
0038   struct DCSBoardUtility {
0039     DCSBoardType boardType;
0040     DCSBoardUtility(const DCSBoardType boardType_) : boardType(boardType_) {}
0041 
0042     /**
0043      * @brief  Get DCSBoardType from string
0044      * @param  board Board name in string format
0045      * @return DCSBoardType for the string given
0046      */
0047     static DCSBoardType getDCSBoard(const std::string board) {
0048       if (board.compare("ALCT"))
0049         return ALCT;
0050       if (board.compare("CFEB"))
0051         return CFEB;
0052       if (board.compare("DMB"))
0053         return DMB;
0054       return ANY;
0055     }
0056 
0057     friend std::ostream& operator<<(std::ostream& out, const DCSBoardUtility& b) {
0058       switch (b.boardType) {
0059         case ANY:
0060           return out << "ANY";
0061         case ALCT:
0062           return out << "ALCT";
0063         case CFEB:
0064           return out << "CFEB";
0065         case DMB:
0066           return out << "DMB";
0067       }
0068       return out << "?";
0069     }
0070   };
0071 
0072   /**
0073    * DCS Address Type to store and manipulate DCS-related address
0074    */
0075   struct DCSAddressType {
0076     /** Endcap: 1 - plus, 2 - minus */
0077     unsigned short iendcap;
0078 
0079     /** Station number */
0080     unsigned short istation;
0081 
0082     /** Ring number */
0083     unsigned short iring;
0084 
0085     /** Chamber number */
0086     unsigned int ichamber;
0087 
0088     /** Get CSC Detector Id object from the address */
0089     CSCDetId getDetId() const { return CSCDetId(iendcap, istation, iring, ichamber); }
0090 
0091     /** Output stream operator */
0092     friend std::ostream& operator<<(std::ostream& out, const DCSAddressType& a) {
0093       std::ostringstream os;
0094       os << "endcap = " << a.iendcap << " ";
0095       os << "station = " << a.istation << " ";
0096       os << "ring = " << a.iring << " ";
0097       os << "chamber = " << a.ichamber;
0098       return out << os.str();
0099     }
0100 
0101     COND_SERIALIZABLE;
0102   };
0103 
0104 }  // namespace cscdqm
0105 
0106 #endif