Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:47:23

0001 #ifndef PixelROCName_h
0002 #define PixelROCName_h
0003 /*! \file CalibFormats/SiPixelObjects/interface/PixelROCName.h
0004 *   \brief This class stores the name and related hardware mappings for a ROC
0005 *
0006 *    A longer explanation will be placed here later
0007 */
0008 
0009 #include <iostream>
0010 #include <fstream>
0011 #include <string>
0012 #include <cassert>
0013 
0014 namespace pos {
0015   /*! \class PixelROCName PixelROCName.h "interface/PixelROCName.h"
0016 *   \brief This class implements..
0017 *
0018 *   A longer explanation will be placed here later
0019 */
0020   class PixelROCName;
0021   std::ostream& operator<<(std::ostream& s, const PixelROCName& pixelroc);
0022 
0023   class PixelROCName {
0024   public:
0025     PixelROCName();
0026 
0027     explicit PixelROCName(std::string rocname);
0028 
0029     explicit PixelROCName(std::ifstream& s);
0030 
0031     std::string rocname() const;
0032 
0033     char detsub() const { return (id_ & 0x80000000) ? 'B' : 'F'; }
0034     char mp() const { return id_ & 0x40000000 ? 'p' : 'm'; }
0035     char IO() const { return id_ & 0x20000000 ? 'I' : 'O'; }
0036     int roc() const { return id_ & 0xf; }
0037 
0038     //These methods only for FPix
0039     int disk() const {
0040       assert((id_ & 0x80000000) == 0);
0041       return (id_ >> 12) & 0x3;
0042     }
0043     int blade() const {
0044       assert((id_ & 0x80000000) == 0);
0045       return (id_ >> 7) & 0x1f;
0046     }
0047     int panel() const {
0048       assert((id_ & 0x80000000) == 0);
0049       return ((id_ >> 6) & 0x1) + 1;
0050     }
0051     int plaquet() const {
0052       assert((id_ & 0x80000000) == 0);
0053       return ((id_ >> 4) & 0x3) + 1;
0054     }
0055 
0056     //These methods only for BPix
0057     int sec() const {
0058       assert((id_ & 0x80000000) != 0);
0059       return ((id_ >> 14) & 0x7) + 1;
0060     }
0061     int layer() const {
0062       assert((id_ & 0x80000000) != 0);
0063       return (id_ >> 12) & 0x3;
0064     }
0065     int ladder() const {
0066       assert((id_ & 0x80000000) != 0);
0067       return (id_ >> 6) & 0x1f;
0068     }
0069     char HF() const {
0070       assert((id_ & 0x80000000) != 0);
0071       return id_ & 0x00000800 ? 'F' : 'H';
0072     }
0073     int module() const {
0074       assert((id_ & 0x80000000) != 0);
0075       return ((id_ >> 4) & 0x3) + 1;
0076     }
0077 
0078     friend std::ostream& pos::operator<<(std::ostream& s, const PixelROCName& pixelroc);
0079 
0080     const PixelROCName& operator=(const PixelROCName& aROC);
0081 
0082     const bool operator<(const PixelROCName& aROC) const { return id_ < aROC.id_; }
0083 
0084     const bool operator==(const PixelROCName& aROC) const { return id_ == aROC.id_; }
0085 
0086     unsigned int id() const { return id_; }
0087 
0088   private:
0089     void parsename(std::string name);
0090 
0091     void check(bool check, const std::string& name);
0092 
0093     void setIdFPix(char np, char LR, int disk, int blade, int panel, int plaquet, int roc);
0094 
0095     void setIdBPix(char np, char LR, int sec, int layer, int ladder, char HF, int module, int roc);
0096 
0097     //BPix_BpI_SEC1_LYR1_LDR3F_MOD1_ROC0
0098 
0099     //The id_ holds the following values for BPix
0100     //bit [0,1,2,3] the ROC #
0101     //bit [4,5] the module#
0102     //bit [6,7,8,9,10] the ladder#
0103     //bit [11] H or F (0 or 1)#
0104     //bit [12,13] the layer#
0105     //bit [14,15,16] the section#
0106     //bit [29] I or 0 (0 or 1)
0107     //bit [30] m or p (0 or 1)
0108     //bit [31] = 1
0109 
0110     //FPix_BpI_D1_BLD1_PNL1_PLQ1_ROC1
0111 
0112     //The id_ holds the following values for FPix
0113     //bit [0,1,2,3] the ROC #
0114     //bit [4,5] the plaquet#
0115     //bit [6] the panel#
0116     //bit [7,8,9,10,11] the blade#
0117     //bit [12,13] the disk#
0118     //bit [29] I or O (0 or 1)
0119     //bit [30] m or p (0 or 1)
0120     //bit [31] = 0
0121 
0122     unsigned int id_;
0123   };
0124 }  // namespace pos
0125 #endif