CMS 3D CMS Logo

ETLDetLayerGeometryBuilder.cc
Go to the documentation of this file.
1 //#define EDM_ML_DEBUG
2 
4 
10 
14 
15 #include <iostream>
16 
17 using namespace std;
18 
19 pair<vector<DetLayer*>, vector<DetLayer*> > ETLDetLayerGeometryBuilder::buildLayers(const MTDGeometry& geo,
20  const MTDTopology& topo) {
21  vector<DetLayer*> result[2]; // one for each endcap
22 
23  const int mtdTopologyMode = topo.getMTDTopologyMode();
25  // number of layers is identical for post TDR scenarios, pick v4
26  // loop on number of sectors per face, two faces per disc (i.e. layer) taken into account in layer building (front/back)
27  unsigned int nSector(1);
28  if (etlL == ETLDetId::EtlLayout::v4) {
29  nSector *= ETLDetId::kETLv4maxSector;
30  } else if (etlL == ETLDetId::EtlLayout::v5) {
31  nSector *= ETLDetId::kETLv5maxSector;
32  } else if (etlL == ETLDetId::EtlLayout::v8) {
33  nSector *= ETLDetId::kETLv5maxSector;
34  } else {
35  throw cms::Exception("MTDDetLayers") << "Not implemented scenario " << mtdTopologyMode;
36  }
37 
38  for (unsigned endcap = 0; endcap < 2; ++endcap) {
39  // number of layers is two, identical for post TDR scenarios, pick v4
40  for (unsigned layer = 1; layer <= ETLDetId::kETLv4nDisc; ++layer) {
41  vector<unsigned> sectors;
42  sectors.reserve(nSector + 1);
43  for (unsigned sector = 1; sector <= nSector; ++sector) {
44  sectors.push_back(sector);
45  }
46  MTDSectorForwardDoubleLayer* thelayer = buildLayer(endcap, layer, sectors, geo, topo);
47  if (thelayer)
48  result[endcap].push_back(thelayer);
49  }
50  }
51  //
52  // the first entry is Z+ ( MTD side 1), the second is Z- (MTD side 0)
53  //
54  pair<vector<DetLayer*>, vector<DetLayer*> > res_pair(result[1], result[0]);
55  return res_pair;
56 }
57 
58 bool ETLDetLayerGeometryBuilder::isFront(int layer, int ring, int module) { return (module + 1) % 2; }
59 
61  int endcap, int layer, vector<unsigned>& sectors, const MTDGeometry& geo, const MTDTopology& topo) {
63 
64  std::vector<const MTDDetSector*> frontSectors, backSectors;
65 
66  LogDebug("MTDDetLayers") << "ETL dets array size = " << geo.detsETL().size();
67 
68  for (unsigned sector : sectors) {
69  std::vector<const GeomDet*> frontGeomDets, backGeomDets;
70  LogDebug("MTDDetLayers") << "endcap = " << endcap << " layer = " << layer << " sector = " << sector;
71 #ifdef EDM_ML_DEBUG
72  unsigned int nfront(0), nback(0);
73 #endif
74  for (auto det : geo.detsETL()) {
75  ETLDetId theMod(det->geographicalId().rawId());
76  if (theMod.mtdSide() == endcap && theMod.nDisc() == layer && theMod.sector() == static_cast<int>(sector)) {
77  LogTrace("MTDLayerDump") << std::fixed << "ETLDetId " << theMod.rawId() << " side = " << std::setw(4)
78  << theMod.mtdSide() << " Disc/Side/Sector = " << std::setw(4) << theMod.nDisc() << " "
79  << std::setw(4) << theMod.discSide() << " " << std::setw(4) << theMod.sector()
80  << " mod/type = " << std::setw(4) << theMod.module() << " " << std::setw(4)
81  << theMod.modType() << " pos = " << det->position();
82  // front layer face
83  if (theMod.discSide() == 0) {
84 #ifdef EDM_ML_DEBUG
85  nfront++;
86  LogTrace("MTDDetLayers") << "Front " << theMod.discSide() << " " << nfront;
87 #endif
88  frontGeomDets.emplace_back(det);
89  // back layer face
90  } else if (theMod.discSide() == 1) {
91 #ifdef EDM_ML_DEBUG
92  nback++;
93  LogTrace("MTDDetLayers") << "Back " << theMod.discSide() << " " << nback;
94 #endif
95  backGeomDets.emplace_back(det);
96  }
97  }
98  }
99 
100  if (!backGeomDets.empty()) {
101  std::sort(backGeomDets.begin(), backGeomDets.end(), topo.orderETLSector);
102  LogDebug("MTDDetLayers") << "backGeomDets size = " << backGeomDets.size();
103  backSectors.emplace_back(makeDetSector(backGeomDets, topo));
104  }
105 
106  if (!frontGeomDets.empty()) {
107  std::sort(frontGeomDets.begin(), frontGeomDets.end(), topo.orderETLSector);
108  LogDebug("MTDDetLayers") << "frontGeomDets size = " << frontGeomDets.size();
109  frontSectors.emplace_back(makeDetSector(frontGeomDets, topo));
110  assert(!backGeomDets.empty());
111  float frontz = frontSectors.back()->position().z();
112  float backz = backSectors.back()->position().z();
113  assert(std::abs(frontz) < std::abs(backz));
114  }
115  }
116 
117  result = new MTDSectorForwardDoubleLayer(frontSectors, backSectors);
118  LogTrace("MTDDetLayers") << "New MTDSectorForwardDoubleLayer with " << std::fixed << std::setw(14)
119  << frontSectors.size() << " and " << std::setw(14) << backSectors.size() << " rings, at Z "
120  << std::setw(14) << result->specificSurface().position().z() << " R1: " << std::setw(14)
121  << result->specificSurface().innerRadius() << " R2: " << std::setw(14)
122  << result->specificSurface().outerRadius();
123 
124  return result;
125 }
126 
127 MTDDetSector* ETLDetLayerGeometryBuilder::makeDetSector(vector<const GeomDet*>& geomDets, const MTDTopology& topo) {
128  MTDDetSector* result = new MTDDetSector(geomDets, topo);
129  LogTrace("MTDDetLayers") << "ETLDetLayerGeometryBuilder::makeDetSector new MTDDetSector with " << std::fixed
130  << std::setw(14) << geomDets.size() << " modules \n"
131  << (*result);
132 
133  return result;
134 }
static MTDDetSector * makeDetSector(std::vector< const GeomDet *> &geomDets, const MTDTopology &topo)
int getMTDTopologyMode() const
Definition: MTDTopology.h:27
static MTDSectorForwardDoubleLayer * buildLayer(int endcap, int layer, std::vector< unsigned > &sectors, const MTDGeometry &geo, const MTDTopology &topo)
const DetContainer & detsETL() const
Definition: MTDGeometry.cc:161
assert(be >=bs)
#define LogTrace(id)
static bool isFront(int layer, int ring, int module)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static bool orderETLSector(const GeomDet *&gd1, const GeomDet *&gd2)
Definition: MTDTopology.cc:8
static constexpr int kETLv5maxSector
Definition: ETLDetId.h:48
ETLDetId::EtlLayout etlLayoutFromTopoMode(const int &topoMode)
static constexpr int kETLv4maxSector
Definition: ETLDetId.h:43
Detector identifier class for the Endcap Timing Layer.
Definition: ETLDetId.h:16
static std::pair< std::vector< DetLayer * >, std::vector< DetLayer * > > buildLayers(const MTDGeometry &geo, const MTDTopology &topo)
static constexpr int kETLv4nDisc
Definition: ETLDetId.h:45
#define LogDebug(id)