CMS 3D CMS Logo

MTDTopology.cc
Go to the documentation of this file.
4 
5 MTDTopology::MTDTopology(const int& topologyMode, const ETLValues& etl)
6  : mtdTopologyMode_(topologyMode), etlVals_(etl) {}
7 
8 bool MTDTopology::orderETLSector(const GeomDet*& gd1, const GeomDet*& gd2) {
9  ETLDetId det1(gd1->geographicalId().rawId());
10  ETLDetId det2(gd2->geographicalId().rawId());
11 
12  if (det1.mtdRR() != det2.mtdRR()) {
13  return det1.mtdRR() < det2.mtdRR();
14  } else if (det1.modType() != det2.modType()) {
15  return det1.modType() < det2.modType();
16  } else if (det1.module() != det2.module()) {
17  return det1.module() < det2.module();
18  } else {
19  return det1.sensor() < det2.sensor();
20  }
21 }
22 
23 size_t MTDTopology::hshiftETL(const uint32_t detid, const int horizontalShift) const {
24  ETLDetId start_mod(detid);
25 
26  if (horizontalShift == 0) {
27  edm::LogWarning("MTDTopology") << "asking of a null horizotalShift in ETL";
28  return failIndex_;
29  }
30  int hsh = horizontalShift > 0 ? 1 : -1;
31 
32  int sensor = start_mod.sensor();
33  int module = start_mod.module();
34  uint32_t modtyp = start_mod.modType();
35  uint32_t discside = start_mod.discSide();
36  int geomDetIndex;
37 
38  // distinguish numbering in prev8 / v8 geometries
39  if (getMTDTopologyMode() == static_cast<int>(MTDTopologyMode::Mode::btlv3etlv8)) {
40  geomDetIndex = 2 * (module - 1) + sensor;
41  } else {
42  geomDetIndex = module;
43  }
44 
45  // ilayout number coincides at present with disc face, use this
46 
47  size_t iHome = (modtyp == etlVals_[discside].idDetType1_) ? 0 : 1;
48  size_t iLeft = (etlVals_[discside].idDetType1_ == 1) ? 0 : 1;
49 
50  // for left type modules the position according to the default order is module - 1, for the rigth type modules the total number of left modules must be added
51 
52  size_t nmodOffset = (modtyp == 1) ? 0 : etlVals_[discside].start_copy_[iLeft].back() - 1;
53 
54  for (size_t iloop = 0; iloop < etlVals_[discside].start_copy_[iHome].size() - 1; iloop++) {
55  if (geomDetIndex >= etlVals_[discside].start_copy_[iHome][iloop] &&
56  geomDetIndex < etlVals_[discside].start_copy_[iHome][iloop + 1]) {
57  if (geomDetIndex + hsh >= etlVals_[discside].start_copy_[iHome][iloop] &&
58  geomDetIndex + hsh < etlVals_[discside].start_copy_[iHome][iloop + 1]) {
59  return geomDetIndex + hsh - 1 + nmodOffset;
60  }
61  break;
62  }
63  }
64 
65  return failIndex_;
66 }
67 
68 size_t MTDTopology::vshiftETL(const uint32_t detid, const int verticalShift, size_t& closest) const {
70 
71  ETLDetId start_mod(detid);
72 
73  if (verticalShift == 0) {
74  edm::LogWarning("MTDTopology") << "asking of a null verticalShift in ETL";
75  return failIndex_;
76  }
77  int vsh = verticalShift > 0 ? 1 : -1;
78 
79  int sensor = start_mod.sensor();
80  int module = start_mod.module();
81  uint32_t modtyp = start_mod.modType();
82  uint32_t discside = start_mod.discSide();
83  int geomDetIndex;
84 
85  // distinguish numbering in prev8 / v8 geometries
86  if (getMTDTopologyMode() == static_cast<int>(MTDTopologyMode::Mode::btlv3etlv8)) {
87  geomDetIndex = 2 * (module - 1) + sensor;
88  } else {
89  geomDetIndex = module;
90  }
91 
92  // ilayout number coincides at present with disc face, use this
93 
94  size_t iHome = (modtyp == etlVals_[discside].idDetType1_) ? 0 : 1;
95  size_t iOther = (iHome == 0) ? 1 : 0;
96  size_t iLeft = (etlVals_[discside].idDetType1_ == 1) ? 0 : 1;
97 
98  // for right type modules the offset of the total number of left modules needs to be added,
99  // what matters here is the other type, i.e. if the starting module is left the vertical shift moves towards a right type, and viceversa
100 
101  size_t nmodOffset = (modtyp == 1) ? etlVals_[discside].start_copy_[iLeft].back() - 1 : 0;
102 
103  size_t iBin(etlVals_[discside].start_copy_[iHome].size()); // never allowed
104  for (size_t iloop = 0; iloop < etlVals_[discside].start_copy_[iHome].size() - 1; iloop++) {
105  if (geomDetIndex >= etlVals_[discside].start_copy_[iHome][iloop] &&
106  geomDetIndex < etlVals_[discside].start_copy_[iHome][iloop + 1]) {
107  iBin = iloop;
108  break;
109  }
110  }
111 
112  if (iBin == etlVals_[discside].start_copy_[iHome].size()) {
113  edm::LogWarning("MTDTopology") << "Module number not compatible with layout, abort";
114  return failIndex_;
115  }
116 
117  // define the interval of interest for the other type according to the vertical shift sign
118 
119  int iBinOther(iBin);
120  if (iHome == 0 && vsh < 0) {
121  iBinOther = iBin - 1;
122  }
123  if (iHome == 1 && vsh > 0) {
124  iBinOther = iBin + 1;
125  }
126  if (iBinOther < 0 || iBinOther >= static_cast<int>(etlVals_[discside].start_copy_[iOther].size()) - 1) {
127  return failIndex_;
128  }
129 
130  // determine the position of the other type corresponding to the same column of the home type
131 
132  int vpos = etlVals_[discside].offset_[iHome][iBin] + geomDetIndex - etlVals_[discside].start_copy_[iHome][iBin] + 1;
133  if (vpos <= etlVals_[discside].offset_[iOther][iBinOther]) {
134  closest = etlVals_[discside].start_copy_[iOther][iBinOther];
135  } else if (vpos > etlVals_[discside].offset_[iOther][iBinOther] +
136  etlVals_[discside].start_copy_[iOther][iBinOther + 1] -
137  etlVals_[discside].start_copy_[iOther][iBinOther] ||
138  (vpos == etlVals_[discside].offset_[iOther][iBinOther] +
139  etlVals_[discside].start_copy_[iOther][iBinOther + 1] -
140  etlVals_[discside].start_copy_[iOther][iBinOther] &&
141  iBinOther + 1 == static_cast<int>(etlVals_[discside].start_copy_[iOther].size()))) {
142  closest = etlVals_[discside].start_copy_[iOther][iBinOther + 1] - 1;
143  }
144  if (closest < failIndex_) {
145  closest = closest + nmodOffset - 1;
146  return failIndex_;
147  } else {
148  // number of module shifted by 1 wrt the position in the array (i.e. module 1 has index 0)
149  return etlVals_[discside].start_copy_[iOther][iBinOther] + vpos - 1 -
150  etlVals_[discside].offset_[iOther][iBinOther] + nmodOffset - 1;
151  }
152 }
size
Write out results.
size_t hshiftETL(const uint32_t detid, const int horizontalShift) const
Definition: MTDTopology.cc:23
int getMTDTopologyMode() const
Definition: MTDTopology.h:27
int closest(std::vector< int > const &vec, int value)
std::vector< ETLfaceLayout > ETLValues
Definition: MTDTopology.h:23
int modType() const
Definition: ETLDetId.h:136
const ETLValues etlVals_
Definition: MTDTopology.h:42
int sensor() const
Definition: ETLDetId.h:139
int module() const
Definition: ETLDetId.h:133
MTDTopology(const int &topologyMode, const ETLValues &etl)
Definition: MTDTopology.cc:5
static bool orderETLSector(const GeomDet *&gd1, const GeomDet *&gd2)
Definition: MTDTopology.cc:8
int mtdRR() const
Definition: MTDDetId.h:64
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
int discSide() const
Definition: ETLDetId.h:150
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
Detector identifier class for the Endcap Timing Layer.
Definition: ETLDetId.h:16
size_t vshiftETL(const uint32_t detid, const int verticalShift, size_t &closest) const
Definition: MTDTopology.cc:68
static constexpr size_t failIndex_
Definition: MTDTopology.h:44
Log< level::Warning, false > LogWarning