File indexing completed on 2024-04-06 11:58:13
0001 #ifndef PixelROCName_h
0002 #define PixelROCName_h
0003
0004
0005
0006
0007
0008
0009 #include <iostream>
0010 #include <fstream>
0011 #include <string>
0012 #include <cassert>
0013
0014 namespace pos {
0015
0016
0017
0018
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
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
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 bool operator<(const PixelROCName& aROC) const { return id_ < aROC.id_; }
0081
0082 const bool operator==(const PixelROCName& aROC) const { return id_ == aROC.id_; }
0083
0084 unsigned int id() const { return id_; }
0085
0086 private:
0087 void parsename(std::string name);
0088
0089 void check(bool check, const std::string& name);
0090
0091 void setIdFPix(char np, char LR, int disk, int blade, int panel, int plaquet, int roc);
0092
0093 void setIdBPix(char np, char LR, int sec, int layer, int ladder, char HF, int module, int roc);
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120 unsigned int id_;
0121 };
0122 }
0123 #endif