CMS 3D CMS Logo

LayerNumberConverter.h
Go to the documentation of this file.
1 #ifndef RecoTracker_MkFitCMS_interface_LayerNumberConverter_h
2 #define RecoTracker_MkFitCMS_interface_LayerNumberConverter_h
3 
4 #include <stdexcept>
5 
6 namespace mkfit {
7 
8  enum struct TkLayout { phase0 = 0, phase1 = 1, phase2 = 2 };
9 
11  public:
14  unsigned int nLayers() const {
15  if (lo_ == TkLayout::phase0)
16  return 69;
17  if (lo_ == TkLayout::phase1)
18  return 72;
19  if (lo_ == TkLayout::phase2)
20  return 60; // 4 + 12 + 2*(12 + 10) = 16 + 22 + 22 = 60
21  return 10;
22  }
23  TkLayout getEra() const { return lo_; }
24  bool isPhase1() const { return lo_ == TkLayout::phase1; }
25  bool isPhase2() const { return lo_ == TkLayout::phase2; }
26  int convertLayerNumber(int det, int lay, bool useMatched, int isStereo, bool posZ) const {
27  if (lo_ == TkLayout::phase2) {
28  if (det == 1)
29  return lay - 1;
30  if (det == 2)
31  return 16 + lay - 1 + (posZ ? 0 : 22);
32  if (det == 5)
33  return 4 + (2 * (lay - 1)) + isStereo;
34  if (det == 4)
35  return 16 + 12 + (2 * (lay - 1)) + isStereo + (posZ ? 0 : 22);
36  throw std::runtime_error("bad subDet");
37  }
38 
39  if (det == 1 || det == 3 || det == 5) {
40  return convertBarrelLayerNumber(det, lay, useMatched, isStereo);
41  } else {
42  int disk = convertDiskNumber(det, lay, useMatched, isStereo);
43  if (disk < 0)
44  return -1;
45 
46  int lOffset = 0;
47  if (lo_ == TkLayout::phase1)
48  lOffset = 1;
49  disk += 17 + lOffset;
50  if (!posZ)
51  disk += 25 + 2 * lOffset;
52  return disk;
53  }
54  return -1;
55  }
56  bool doesHaveStereo(int det, int lay) const {
57  if (lo_ == TkLayout::phase2) {
58  if (det == 1 || det == 2)
59  return false;
60  if (det == 4 || det == 5)
61  return true;
62  throw std::runtime_error("bad subDet");
63  }
64  if (det == 3 || det == 5) {
65  return lay == 1 || lay == 2;
66  }
67  if (det == 4 || det == 6) {
68  return true;
69  }
70  return false;
71  }
72 
73  int convertBarrelLayerNumber(int cmsswdet, int cmsswlay, bool useMatched, int isStereo) const {
74  int lOffset = 0;
75  if (lo_ == TkLayout::phase1)
76  lOffset = 1;
77  if (cmsswdet == 2 || cmsswdet == 4 || cmsswdet == 6)
78  return -1; //FPIX, TID, TEC
79  if (cmsswdet == 1)
80  return cmsswlay - 1; //BPIX
81  if (useMatched) {
82  //TIB
83  if (cmsswdet == 3) {
84  if (cmsswlay == 1 && isStereo == -1)
85  return 3 + lOffset;
86  else if (cmsswlay == 2 && isStereo == -1)
87  return 4 + lOffset;
88  else if (cmsswlay == 3 && isStereo == 0)
89  return 5 + lOffset;
90  else if (cmsswlay == 4 && isStereo == 0)
91  return 6 + lOffset;
92  }
93  //TOB
94  else if (cmsswdet == 5) {
95  if (cmsswlay == 1 && isStereo == -1)
96  return 7 + lOffset;
97  else if (cmsswlay == 2 && isStereo == -1)
98  return 8 + lOffset;
99  else if (cmsswlay >= 3 && cmsswlay <= 6 && isStereo == 0)
100  return 6 + cmsswlay + lOffset;
101  }
102  return -1;
103  } else {
104  //TIB
105  if (cmsswdet == 3) {
106  if ((cmsswlay == 1 || cmsswlay == 2) && (isStereo == 0 || isStereo == 1)) {
107  return 1 + cmsswlay * 2 + isStereo + lOffset;
108  } else if (cmsswlay == 3 && isStereo == 0)
109  return 7 + lOffset;
110  else if (cmsswlay == 4 && isStereo == 0)
111  return 8 + lOffset;
112  }
113  //TOB
114  else if (cmsswdet == 5) {
115  if ((cmsswlay == 1 || cmsswlay == 2) && (isStereo == 0 || isStereo == 1)) {
116  return 7 + cmsswlay * 2 + isStereo + lOffset;
117  } else if (cmsswlay >= 3 && cmsswlay <= 6 && isStereo == 0)
118  return 10 + cmsswlay + lOffset;
119  }
120  return -1;
121  }
122  }
123  int convertDiskNumber(int cmsswdet, int cmsswdisk, bool useMatched, int isStereo) const {
124  if (cmsswdet == 1 || cmsswdet == 3 || cmsswdet == 5)
125  return -1; //BPIX, TIB, TOB
126  if (cmsswdet == 2)
127  return cmsswdisk - 1; //FPIX
128  int lOffset = 0;
129  if (lo_ == TkLayout::phase1)
130  lOffset = 1;
131  if (useMatched) {
132  return -1;
133  } else {
134  if ((isStereo != 0 && isStereo != 1) || cmsswdisk < 1)
135  return -1;
136  //TID
137  if (cmsswdet == 4 && cmsswdisk <= 3)
138  return cmsswdisk * 2 + isStereo + lOffset;
139  //TEC
140  else if (cmsswdet == 6 && cmsswdisk <= 9)
141  return 6 + cmsswdisk * 2 + isStereo + lOffset;
142  return -1;
143  }
144  }
145 
146  private:
148  };
149 
150 } // end namespace mkfit
151 
152 #endif
constexpr bool useMatched
int convertDiskNumber(int cmsswdet, int cmsswdisk, bool useMatched, int isStereo) const
bool doesHaveStereo(int det, int lay) const
int convertBarrelLayerNumber(int cmsswdet, int cmsswlay, bool useMatched, int isStereo) const
int convertLayerNumber(int det, int lay, bool useMatched, int isStereo, bool posZ) const