CMS 3D CMS Logo

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