CMS 3D CMS Logo

MuonGEMDetLayerGeometryBuilder.cc
Go to the documentation of this file.
2 
9 
12 
14 
15 #include <iostream>
16 
17 using namespace std;
18 
20 
21 // Builds the forward (first) and backward (second) layers
22 // Builds etaPartitions (for rechits)
23 pair<vector<DetLayer*>, vector<DetLayer*> > MuonGEMDetLayerGeometryBuilder::buildEndcapLayers(const GEMGeometry& geo) {
24  vector<DetLayer*> endcapLayers[2];
25 
26  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuonGEMDetLayerGeometryBuilder";
27  for (auto st : geo.stations()) {
28  const int maxLayerId = (st->station() == GEMDetId::minStationId0) ? GEMDetId::maxLayerId0 : GEMDetId::maxLayerId;
29  for (int layer = GEMDetId::minLayerId + 1; layer <= maxLayerId; ++layer) {
30  ForwardDetLayer* forwardLayer = nullptr;
31  vector<const ForwardDetRing*> frontRings, backRings;
32 
33  for (int roll = GEMDetId::minRollId + 1; roll <= GEMDetId::maxRollId; ++roll) {
34  vector<const GeomDet*> frontDets, backDets;
35 
36  for (auto sc : st->superChambers()) {
37  auto ch = sc->chamber(layer);
38  if (ch == nullptr)
39  continue;
40 
41  auto etaP = ch->etaPartition(roll);
42  if (etaP == nullptr)
43  continue;
44 
45  bool isInFront = isFront(etaP->id());
46  if (isInFront) {
47  frontDets.push_back(etaP);
48  } else {
49  backDets.push_back(etaP);
50  }
51  }
52 
53  if (!frontDets.empty()) {
54  precomputed_value_sort(frontDets.begin(), frontDets.end(), geomsort::DetPhi());
55  frontRings.push_back(new MuDetRing(frontDets));
56  LogTrace(metname) << "New front ring with " << frontDets.size()
57  << " chambers at z=" << frontRings.back()->position().z();
58  }
59  if (!backDets.empty()) {
60  precomputed_value_sort(backDets.begin(), backDets.end(), geomsort::DetPhi());
61  backRings.push_back(new MuDetRing(backDets));
62  LogTrace(metname) << "New back ring with " << backDets.size()
63  << " chambers at z=" << backRings.back()->position().z();
64  }
65  }
66 
67  if (!frontRings.empty()) {
68  if (st->station() == GEMDetId::minStationId0)
69  forwardLayer = new MuRingForwardLayer(frontRings);
70  else if (!backRings.empty())
71  forwardLayer = new MuRingForwardDoubleLayer(frontRings, backRings);
72  }
73 
74  if (forwardLayer != nullptr) {
75  LogTrace(metname) << "New MuRingForwardLayer with " << frontRings.size() << " and " << backRings.size()
76  << " rings, at Z " << forwardLayer->position().z()
77  << " R1: " << forwardLayer->specificSurface().innerRadius()
78  << " R2: " << forwardLayer->specificSurface().outerRadius();
79 
80  int iendcap = (st->region() == 1) ? 0 : 1;
81  endcapLayers[iendcap].push_back(forwardLayer);
82  }
83  }
84  }
85 
86  pair<vector<DetLayer*>, vector<DetLayer*> > res_pair(endcapLayers[0], endcapLayers[1]);
87  return res_pair;
88 }
89 
91  // ME0s do not currently have an arrangement of which are front and which are back, going to always return true
92  if (gemId.station() == GEMDetId::minStationId0)
93  return true;
94 
95  return (gemId.chamber() % 2 == 0);
96 }
97 
98 MuDetRing* MuonGEMDetLayerGeometryBuilder::makeDetRing(vector<const GeomDet*>& geomDets) {
99  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuonGEMDetLayerGeometryBuilder";
100 
101  precomputed_value_sort(geomDets.begin(), geomDets.end(), geomsort::DetPhi());
102  MuDetRing* result = new MuDetRing(geomDets);
103  LogTrace(metname) << "New MuDetRing with " << geomDets.size() << " chambers at z=" << result->position().z()
104  << " R1: " << result->specificSurface().innerRadius()
105  << " R2: " << result->specificSurface().outerRadius();
106  return result;
107 }
constexpr int station() const
Definition: GEMDetId.h:179
virtual const Surface::PositionType & position() const
Returns position of the surface.
ExtractPhi< GeomDet, float > DetPhi
Definition: DetSorting.h:37
T z() const
Definition: PV3DBase.h:61
const std::string metname
const std::vector< const GEMStation * > & stations() const
Return a vector of all GEM stations.
Definition: GEMGeometry.cc:32
constexpr int chamber() const
Definition: GEMDetId.h:183
static constexpr int32_t maxLayerId0
Definition: GEMDetId.h:31
#define LogTrace(id)
static constexpr int32_t minStationId0
Definition: GEMDetId.h:24
static bool isFront(const GEMDetId &gemId)
static MuDetRing * makeDetRing(std::vector< const GeomDet *> &geomDets)
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr, const Compare &comp)
static constexpr int32_t minRollId
Definition: GEMDetId.h:35
static constexpr int32_t maxLayerId
Definition: GEMDetId.h:32
virtual const BoundDisk & specificSurface() const final
static constexpr int32_t minLayerId
Definition: GEMDetId.h:30
static constexpr int32_t maxRollId
Definition: GEMDetId.h:36
static std::pair< std::vector< DetLayer * >, std::vector< DetLayer * > > buildEndcapLayers(const GEMGeometry &geo)