Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:58:13

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