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