Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-06-04 06:14:10

0001 #ifndef CondFormats_CSCReadoutMapping_h
0002 #define CondFormats_CSCReadoutMapping_h
0003 
0004 /** 
0005  * \class CSCReadoutMapping
0006  * \author Tim Cox
0007  * Abstract class to define mapping between CSC readout hardware ids and other labels.
0008  *
0009  * Defines the ids and labels in the mapping and supplies translation interface.
0010  * A derived class must define how hardware labels map to a unique integer.
0011  * A derived, concrete, class must define from where the mapping information comes.
0012  */
0013 
0014 //@@ FIXME This whole design would better suit a Factory/Builder pattern
0015 
0016 #include "CondFormats/Serialization/interface/Serializable.h"
0017 
0018 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0019 #include <vector>
0020 #include <map>
0021 
0022 class CSCReadoutMapping {
0023 public:
0024   /// Default constructor
0025   CSCReadoutMapping();
0026 
0027   /// Destructor
0028   virtual ~CSCReadoutMapping();
0029 
0030   /**
0031    * Instead of a set of vectors of int use one vector of a set of ints
0032    */
0033   struct CSCLabel {
0034     CSCLabel() {}
0035     CSCLabel(int endcap,
0036              int station,
0037              int ring,
0038              int chamber,
0039              int vmecrate,
0040              int dmb,
0041              int tmb,
0042              int tsector,
0043              int cscid,
0044              int ddu,
0045              int dcc)
0046         : endcap_(endcap),
0047           station_(station),
0048           ring_(ring),
0049           chamber_(chamber),
0050           vmecrate_(vmecrate),
0051           dmb_(dmb),
0052           tmb_(tmb),
0053           tsector_(tsector),
0054           cscid_(cscid),
0055           ddu_(ddu),
0056           dcc_(dcc) {}
0057     ~CSCLabel() {}
0058 
0059     int endcap_;
0060     int station_;
0061     int ring_;
0062     int chamber_;
0063     int vmecrate_;
0064     int dmb_;
0065     int tmb_;
0066     int tsector_;
0067     int cscid_;
0068     int ddu_;
0069     int dcc_;
0070 
0071     COND_SERIALIZABLE;
0072   };
0073 
0074   /**
0075     * Return CSCDetId for layer corresponding to readout ids vme, tmb, and dmb for given endcap
0076     * and layer no. 1-6, or for chamber if no layer no. supplied.
0077     * Args: endcap = 1 (+z), 2 (-z), station, vme crate number, dmb slot number, tmb slot number, 
0078     * cfeb number (so we can identify ME1a/b within ME11), layer number
0079     */
0080   // layer at end so it can have default arg
0081   CSCDetId detId(int endcap, int station, int vmecrate, int dmb, int tmb, int cfeb, int layer = 0) const;
0082 
0083   /** 
0084     * Return chamber label corresponding to readout ids vme, tmb and dmb for given endcap
0085     *  endcap = 1 (+z), 2 (-z), station, vme crate number, dmb slot number, tmb slot number.
0086     */
0087   int chamber(int endcap, int station, int vmecrate, int dmb, int tmb) const;
0088 
0089   ///returns hardware ids given chamber id
0090   CSCLabel findHardwareId(const CSCDetId&) const;
0091   ///returns vmecrate given CSCDetId
0092   int crate(const CSCDetId&) const;
0093   ///returns dmbId given CSCDetId
0094   int dmbId(const CSCDetId&) const;
0095   ///returns DCC# given CSCDetId
0096   int dccId(const CSCDetId&) const;
0097   ///returns DDU# given CSCDetId
0098   int dduId(const CSCDetId&) const;
0099 
0100   /**
0101     * Add one record of info to mapping
0102     */
0103   void addRecord(int endcap,
0104                  int station,
0105                  int ring,
0106                  int chamber,
0107                  int vmecrate,
0108                  int dmb,
0109                  int tmb,
0110                  int tsector,
0111                  int cscid,
0112                  int ddu,
0113                  int dcc);
0114 
0115   /**
0116      * Set debug printout flag
0117      */
0118   void setDebugV(bool dbg) { debugV_ = dbg; }
0119 
0120   /**
0121      * Status of debug printout flag
0122      */
0123   bool debugV(void) const { return debugV_; }
0124 
0125   /**
0126      * Return class name
0127      */
0128   const std::string& myName(void) const { return myName_; }
0129 
0130 private:
0131   /**
0132      * Build a unique integer out of the readout electronics labels.
0133      *
0134      * In general this must depend on endcap and station, as well as
0135      * vme crate number and dmb slot number. And possibly tmb slot?
0136      */
0137   virtual int hwId(int endcap, int station, int vme, int dmb, int tmb) const = 0;
0138 
0139   /**
0140      * Build a unique integer out of chamber labels.
0141      *
0142      * We'll probably use rawId of CSCDetId... You know it makes sense!
0143      */
0144   int swId(int endcap, int station, int ring, int chamber) const;
0145 
0146   std::string myName_ COND_TRANSIENT;
0147   bool debugV_ COND_TRANSIENT;
0148   std::vector<CSCLabel> mapping_;
0149   std::map<int, int> hw2sw_ COND_TRANSIENT;
0150   std::map<int, CSCLabel> sw2hw_;
0151 
0152   COND_SERIALIZABLE;
0153 };
0154 
0155 #endif