CMS 3D CMS Logo

List of all members | Static Public Member Functions | Private Member Functions | Static Private Member Functions
ETLDetLayerGeometryBuilder Class Reference

#include <ETLDetLayerGeometryBuilder.h>

Static Public Member Functions

static std::pair< std::vector< DetLayer * >, std::vector< DetLayer * > > buildLayers (const MTDGeometry &geo, const MTDTopology &topo)
 

Private Member Functions

 ETLDetLayerGeometryBuilder ()
 

Static Private Member Functions

static MTDRingForwardDoubleLayerbuildLayer (int endcap, int layer, std::vector< unsigned > &rings, const MTDGeometry &geo)
 
static MTDSectorForwardDoubleLayerbuildLayerNew (int endcap, int layer, std::vector< unsigned > &sectors, const MTDGeometry &geo, const MTDTopology &topo)
 
static bool isFront (int layer, int ring, int module)
 
static MTDDetRingmakeDetRing (std::vector< const GeomDet *> &geomDets)
 
static MTDDetSectormakeDetSector (std::vector< const GeomDet *> &geomDets, const MTDTopology &topo)
 

Detailed Description

Build the ETL DetLayers.

Author
L. Gray - FNAL

Definition at line 21 of file ETLDetLayerGeometryBuilder.h.

Constructor & Destructor Documentation

◆ ETLDetLayerGeometryBuilder()

ETLDetLayerGeometryBuilder::ETLDetLayerGeometryBuilder ( )
inlineprivate

Definition at line 30 of file ETLDetLayerGeometryBuilder.h.

30 {}

Member Function Documentation

◆ buildLayer()

MTDRingForwardDoubleLayer * ETLDetLayerGeometryBuilder::buildLayer ( int  endcap,
int  layer,
std::vector< unsigned > &  rings,
const MTDGeometry geo 
)
staticprivate

Definition at line 74 of file ETLDetLayerGeometryBuilder.cc.

References funct::abs(), cms::cuda::assert(), TauDecayModes::dec, makeMuonMisalignmentScenario::endcap, MTDGeometry::idToDet(), ETLDetId::kETLmoduleMask, LogTrace, callgraph::module, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), GeomDet::position(), DetId::rawId(), mps_fire::result, relativeConstraints::ring, and PV3DBase< T, PVType, FrameType >::z().

77  {
79 
80  vector<const ForwardDetRing*> frontRings, backRings;
81 
82  for (unsigned ring : rings) {
83  vector<const GeomDet*> frontGeomDets, backGeomDets;
84  for (unsigned module = 1; module <= ETLDetId::kETLmoduleMask; ++module) {
85  ETLDetId detId(endcap, ring, module, 0);
86  const GeomDet* geomDet = geo.idToDet(detId);
87  // we sometimes loop over more chambers than there are in ring
88  bool isInFront = isFront(layer, ring, module);
89  if (geomDet != nullptr) {
90  if (isInFront) {
91  frontGeomDets.push_back(geomDet);
92  } else {
93  backGeomDets.push_back(geomDet);
94  }
95  LogTrace("MTDDetLayers") << "get ETL module " << std::hex << ETLDetId(endcap, layer, ring, module).rawId()
96  << std::dec << " at R=" << geomDet->position().perp()
97  << ", phi=" << geomDet->position().phi() << ", z= " << geomDet->position().z()
98  << " isFront? " << isInFront;
99  }
100  }
101 
102  if (!backGeomDets.empty()) {
103  backRings.push_back(makeDetRing(backGeomDets));
104  }
105 
106  if (!frontGeomDets.empty()) {
107  frontRings.push_back(makeDetRing(frontGeomDets));
108  assert(!backGeomDets.empty());
109  float frontz = frontRings[0]->position().z();
110  float backz = backRings[0]->position().z();
111  assert(std::abs(frontz) < std::abs(backz));
112  }
113  }
114 
115  // How should they be sorted?
116  // precomputed_value_sort(muDetRods.begin(), muDetRods.end(), geomsort::ExtractZ<GeometricSearchDet,float>());
117  result = new MTDRingForwardDoubleLayer(frontRings, backRings);
118  LogTrace("MTDDetLayers") << "New MTDRingForwardLayer with " << frontRings.size() << " and " << backRings.size()
119  << " rings, at Z " << result->position().z()
120  << " R1: " << result->specificSurface().innerRadius()
121  << " R2: " << result->specificSurface().outerRadius();
122  return result;
123 }
T perp() const
Definition: PV3DBase.h:69
T z() const
Definition: PV3DBase.h:61
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
assert(be >=bs)
#define LogTrace(id)
static bool isFront(int layer, int ring, int module)
constexpr std::array< uint8_t, layerIndexSize > layer
const MTDGeomDet * idToDet(DetId) const override
Definition: MTDGeometry.cc:171
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
static constexpr uint32_t kETLmoduleMask
Definition: ETLDetId.h:24
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:43
Detector identifier class for the Endcap Timing Layer.
Definition: ETLDetId.h:15
static MTDDetRing * makeDetRing(std::vector< const GeomDet *> &geomDets)

◆ buildLayerNew()

MTDSectorForwardDoubleLayer * ETLDetLayerGeometryBuilder::buildLayerNew ( int  endcap,
int  layer,
std::vector< unsigned > &  sectors,
const MTDGeometry geo,
const MTDTopology topo 
)
staticprivate

Definition at line 137 of file ETLDetLayerGeometryBuilder.cc.

References funct::abs(), cms::cuda::assert(), MTDGeometry::detsETL(), makeMuonMisalignmentScenario::endcap, alignBH_cfg::fixed, LogDebug, LogTrace, MTDTopology::orderETLSector(), mps_fire::result, volumeBasedMagneticField_160812_cfi::sectors, and jetsAK4_CHS_cff::sort.

138  {
140 
141  std::vector<const MTDDetSector*> frontSectors, backSectors;
142 
143  LogDebug("MTDDetLayers") << "ETL dets array size = " << geo.detsETL().size();
144 
145  for (unsigned sector : sectors) {
146  std::vector<const GeomDet*> frontGeomDets, backGeomDets;
147  LogDebug("MTDDetLayers") << "endcap = " << endcap << " layer = " << layer << " sector = " << sector;
148 #ifdef EDM_ML_DEBUG
149  unsigned int nfront(0), nback(0);
150 #endif
151  for (auto det : geo.detsETL()) {
152  ETLDetId theMod(det->geographicalId().rawId());
153  if (theMod.mtdSide() == endcap && theMod.nDisc() == layer && theMod.sector() == static_cast<int>(sector)) {
154  LogTrace("MTDLayerDump") << std::fixed << "ETLDetId " << theMod.rawId() << " side = " << std::setw(4)
155  << theMod.mtdSide() << " Disc/Side/Sector = " << std::setw(4) << theMod.nDisc() << " "
156  << std::setw(4) << theMod.discSide() << " " << std::setw(4) << theMod.sector()
157  << " mod/type = " << std::setw(4) << theMod.module() << " " << std::setw(4)
158  << theMod.modType() << " pos = " << det->position();
159  // front layer face
160  if (theMod.discSide() == 0) {
161 #ifdef EDM_ML_DEBUG
162  nfront++;
163  LogTrace("MTDDetLayers") << "Front " << theMod.discSide() << " " << nfront;
164 #endif
165  frontGeomDets.emplace_back(det);
166  // back layer face
167  } else if (theMod.discSide() == 1) {
168 #ifdef EDM_ML_DEBUG
169  nback++;
170  LogTrace("MTDDetLayers") << "Back " << theMod.discSide() << " " << nback;
171 #endif
172  backGeomDets.emplace_back(det);
173  }
174  }
175  }
176 
177  if (!backGeomDets.empty()) {
178  std::sort(backGeomDets.begin(), backGeomDets.end(), topo.orderETLSector);
179  LogDebug("MTDDetLayers") << "backGeomDets size = " << backGeomDets.size();
180  backSectors.emplace_back(makeDetSector(backGeomDets, topo));
181  }
182 
183  if (!frontGeomDets.empty()) {
184  std::sort(frontGeomDets.begin(), frontGeomDets.end(), topo.orderETLSector);
185  LogDebug("MTDDetLayers") << "frontGeomDets size = " << frontGeomDets.size();
186  frontSectors.emplace_back(makeDetSector(frontGeomDets, topo));
187  assert(!backGeomDets.empty());
188  float frontz = frontSectors.back()->position().z();
189  float backz = backSectors.back()->position().z();
190  assert(std::abs(frontz) < std::abs(backz));
191  }
192  }
193 
194  result = new MTDSectorForwardDoubleLayer(frontSectors, backSectors);
195  LogTrace("MTDDetLayers") << "New MTDSectorForwardDoubleLayer with " << std::fixed << std::setw(14)
196  << frontSectors.size() << " and " << std::setw(14) << backSectors.size() << " rings, at Z "
197  << std::setw(14) << result->specificSurface().position().z() << " R1: " << std::setw(14)
198  << result->specificSurface().innerRadius() << " R2: " << std::setw(14)
199  << result->specificSurface().outerRadius();
200 
201  return result;
202 }
static MTDDetSector * makeDetSector(std::vector< const GeomDet *> &geomDets, const MTDTopology &topo)
const DetContainer & detsETL() const
Definition: MTDGeometry.cc:161
assert(be >=bs)
#define LogTrace(id)
constexpr std::array< uint8_t, layerIndexSize > layer
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static bool orderETLSector(const GeomDet *&gd1, const GeomDet *&gd2)
Definition: MTDTopology.cc:7
Detector identifier class for the Endcap Timing Layer.
Definition: ETLDetId.h:15
#define LogDebug(id)

◆ buildLayers()

pair< vector< DetLayer * >, vector< DetLayer * > > ETLDetLayerGeometryBuilder::buildLayers ( const MTDGeometry geo,
const MTDTopology topo 
)
static

return.first=forward (+Z), return.second=backward (-Z) both vectors are sorted inside-out

Definition at line 21 of file ETLDetLayerGeometryBuilder.cc.

References makeMuonMisalignmentScenario::endcap, MTDTopologyMode::etlLayoutFromTopoMode(), Exception, MTDTopology::getMTDTopologyMode(), ETLDetId::kETLv1maxRing, ETLDetId::kETLv1nDisc, ETLDetId::kETLv4maxSector, ETLDetId::kETLv4nDisc, ETLDetId::kETLv5maxSector, mps_fire::result, relativeConstraints::ring, volumeBasedMagneticField_160812_cfi::sectors, ETLDetId::tp, ETLDetId::v4, and ETLDetId::v5.

Referenced by MTDDetLayerGeometry::buildLayers().

22  {
23  vector<DetLayer*> result[2]; // one for each endcap
24 
25  const int mtdTopologyMode = topo.getMTDTopologyMode();
27  if (etlL == ETLDetId::EtlLayout::tp) {
28  for (unsigned endcap = 0; endcap < 2; ++endcap) {
29  // there is only one layer for ETL right now, maybe more later
30  for (unsigned layer = 0; layer < ETLDetId::kETLv1nDisc; ++layer) {
31  vector<unsigned> rings;
32  rings.reserve(ETLDetId::kETLv1maxRing + 1);
33  for (unsigned ring = 1; ring <= ETLDetId::kETLv1maxRing; ++ring) {
34  rings.push_back(ring);
35  }
36  MTDRingForwardDoubleLayer* thelayer = buildLayer(endcap, layer, rings, geo);
37  if (thelayer)
38  result[endcap].push_back(thelayer);
39  }
40  }
41  } else {
42  // number of layers is identical for post TDR scenarios, pick v4
43  // loop on number of sectors per face, two faces per disc (i.e. layer) taken into account in layer building (front/back)
44  unsigned int nSector(1);
45  if (etlL == ETLDetId::EtlLayout::v4) {
46  nSector *= ETLDetId::kETLv4maxSector;
47  } else if (etlL == ETLDetId::EtlLayout::v5) {
48  nSector *= ETLDetId::kETLv5maxSector;
49  } else {
50  throw cms::Exception("MTDDetLayers") << "Not implemented scenario " << mtdTopologyMode;
51  }
52 
53  for (unsigned endcap = 0; endcap < 2; ++endcap) {
54  // number of layers is two, identical for post TDR scenarios, pick v4
55  for (unsigned layer = 1; layer <= ETLDetId::kETLv4nDisc; ++layer) {
56  vector<unsigned> sectors;
57  sectors.reserve(nSector + 1);
58  for (unsigned sector = 1; sector <= nSector; ++sector) {
59  sectors.push_back(sector);
60  }
62  if (thelayer)
63  result[endcap].push_back(thelayer);
64  }
65  }
66  }
67  //
68  // the first entry is Z+ ( MTD side 1), the second is Z- (MTD side 0)
69  //
70  pair<vector<DetLayer*>, vector<DetLayer*> > res_pair(result[1], result[0]);
71  return res_pair;
72 }
int getMTDTopologyMode() const
Definition: MTDTopology.h:27
constexpr std::array< uint8_t, layerIndexSize > layer
static constexpr int kETLv1maxRing
Definition: ETLDetId.h:28
static constexpr int kETLv5maxSector
Definition: ETLDetId.h:45
ETLDetId::EtlLayout etlLayoutFromTopoMode(const int &topoMode)
static constexpr int kETLv4maxSector
Definition: ETLDetId.h:40
static constexpr int kETLv4nDisc
Definition: ETLDetId.h:42
static MTDRingForwardDoubleLayer * buildLayer(int endcap, int layer, std::vector< unsigned > &rings, const MTDGeometry &geo)
static constexpr int kETLv1nDisc
Definition: ETLDetId.h:30
static MTDSectorForwardDoubleLayer * buildLayerNew(int endcap, int layer, std::vector< unsigned > &sectors, const MTDGeometry &geo, const MTDTopology &topo)

◆ isFront()

bool ETLDetLayerGeometryBuilder::isFront ( int  layer,
int  ring,
int  module 
)
staticprivate

Definition at line 125 of file ETLDetLayerGeometryBuilder.cc.

References callgraph::module.

125 { return (module + 1) % 2; }

◆ makeDetRing()

MTDDetRing * ETLDetLayerGeometryBuilder::makeDetRing ( std::vector< const GeomDet *> &  geomDets)
staticprivate

Definition at line 127 of file ETLDetLayerGeometryBuilder.cc.

References LogTrace, precomputed_value_sort(), and mps_fire::result.

127  {
128  precomputed_value_sort(geomDets.begin(), geomDets.end(), geomsort::DetPhi());
129  MTDDetRing* result = new MTDDetRing(geomDets);
130  LogTrace("MTDDetLayers") << "ETLDetLayerGeometryBuilder: new MTDDetRing with " << geomDets.size()
131  << " chambers at z=" << result->position().z()
132  << " R1: " << result->specificSurface().innerRadius()
133  << " R2: " << result->specificSurface().outerRadius();
134  return result;
135 }
ExtractPhi< GeomDet, float > DetPhi
Definition: DetSorting.h:37
#define LogTrace(id)
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr, const Compare &comp)

◆ makeDetSector()

MTDDetSector * ETLDetLayerGeometryBuilder::makeDetSector ( std::vector< const GeomDet *> &  geomDets,
const MTDTopology topo 
)
staticprivate

Definition at line 204 of file ETLDetLayerGeometryBuilder.cc.

References alignBH_cfg::fixed, LogTrace, and mps_fire::result.

204  {
205  MTDDetSector* result = new MTDDetSector(geomDets, topo);
206  LogTrace("MTDDetLayers") << "ETLDetLayerGeometryBuilder::makeDetSector new MTDDetSector with " << std::fixed
207  << std::setw(14) << geomDets.size() << " modules \n"
208  << (*result);
209 
210  return result;
211 }
#define LogTrace(id)