CMS 3D CMS Logo

MuonCSCDetLayerGeometryBuilder.cc
Go to the documentation of this file.
2 
7 
10 
12 
13 #include <iostream>
14 
15 using namespace std;
16 
17 pair<vector<DetLayer*>, vector<DetLayer*> > MuonCSCDetLayerGeometryBuilder::buildLayers(const CSCGeometry& geo) {
18  vector<DetLayer*> result[2]; // one for each endcap
19 
20  for (int i = 0; i < 2; i++) {
21  int endcap = i + 1;
22 
23  // ME/1/1a (= station 1, ring 4) and ME/1/1b (= station 1, ring 1)
24  {
25  vector<int> rings;
26  rings.push_back(4);
27  rings.push_back(1);
28 
29  MuRingForwardDoubleLayer* layer = buildLayer(endcap, 1, rings, geo);
30  if (layer)
31  result[i].push_back(layer);
32  }
33 
34  // ME/1/2 and 1/3 (= station 1, ring 2 and 3)
35  {
36  vector<int> rings;
37  rings.push_back(2);
38  rings.push_back(3);
39 
40  MuRingForwardDoubleLayer* layer = buildLayer(endcap, 1, rings, geo);
41  if (layer)
42  result[i].push_back(layer);
43  }
44 
45  // Stations 2,3,4
46  for (int station = 2; station <= CSCDetId::maxStationId(); station++) {
47  vector<int> rings;
48  for (int ring = CSCDetId::minRingId(); ring <= CSCDetId::maxRingId(); ring++) {
49  rings.push_back(ring);
50  }
51  MuRingForwardDoubleLayer* layer = buildLayer(endcap, station, rings, geo);
52  if (layer)
53  result[i].push_back(layer);
54  }
55  }
56  pair<vector<DetLayer*>, vector<DetLayer*> > res_pair(result[0], result[1]);
57  return res_pair;
58 }
59 
61  int station,
62  vector<int>& rings,
63  const CSCGeometry& geo) {
64  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuonCSCDetLayerGeometryBuilder";
66 
67  vector<const ForwardDetRing*> frontRings, backRings;
68 
69  for (vector<int>::iterator ring = rings.begin(); ring != rings.end(); ring++) {
70  vector<const GeomDet*> frontGeomDets, backGeomDets;
72  CSCDetId detId(endcap, station, (*ring), chamber, 0);
73  const GeomDet* geomDet = geo.idToDet(detId);
74  // we sometimes loop over more chambers than there are in ring
75  bool isInFront = isFront(station, *ring, chamber);
76  if (geomDet != nullptr) {
77  if (isInFront) {
78  frontGeomDets.push_back(geomDet);
79  } else {
80  backGeomDets.push_back(geomDet);
81  }
82  LogTrace(metname) << "get CSC chamber " << CSCDetId(endcap, station, (*ring), chamber, 0)
83  << " at R=" << geomDet->position().perp() << ", phi=" << geomDet->position().phi()
84  << ", z= " << geomDet->position().z() << " isFront? " << isInFront;
85  }
86  }
87 
88  if (!backGeomDets.empty()) {
89  backRings.push_back(makeDetRing(backGeomDets));
90  }
91 
92  if (!frontGeomDets.empty()) {
93  frontRings.push_back(makeDetRing(frontGeomDets));
94  assert(!backGeomDets.empty());
95  float frontz = frontRings[0]->position().z();
96  float backz = backRings[0]->position().z();
97  assert(fabs(frontz) < fabs(backz));
98  }
99  }
100 
101  // How should they be sorted?
102  // precomputed_value_sort(muDetRods.begin(), muDetRods.end(), geomsort::ExtractZ<GeometricSearchDet,float>());
103  result = new MuRingForwardDoubleLayer(frontRings, backRings);
104  LogTrace(metname) << "New MuRingForwardLayer with " << frontRings.size() << " and " << backRings.size()
105  << " rings, at Z " << result->position().z() << " R1: " << result->specificSurface().innerRadius()
106  << " R2: " << result->specificSurface().outerRadius();
107  return result;
108 }
109 
111  bool result = false;
112 
113  bool isOverlapping = !(station == 1 && ring == 3);
114  // not overlapping means back
115  if (isOverlapping) {
116  bool isEven = (chamber % 2 == 0);
117  // odd chambers are bolted to the iron, which faces
118  // forward in 1&2, backward in 3&4, so...
119  result = (station < 3) ? isEven : !isEven;
120  }
121  return result;
122 }
123 
124 MuDetRing* MuonCSCDetLayerGeometryBuilder::makeDetRing(vector<const GeomDet*>& geomDets) {
125  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuonCSCDetLayerGeometryBuilder";
126 
127  precomputed_value_sort(geomDets.begin(), geomDets.end(), geomsort::DetPhi());
128  MuDetRing* result = new MuDetRing(geomDets);
129  LogTrace(metname) << "New MuDetRing with " << geomDets.size() << " chambers at z=" << result->position().z()
130  << " R1: " << result->specificSurface().innerRadius()
131  << " R2: " << result->specificSurface().outerRadius();
132  return result;
133 }
static int minRingId()
Definition: CSCDetId.h:238
T perp() const
Definition: PV3DBase.h:69
ExtractPhi< GeomDet, float > DetPhi
Definition: DetSorting.h:37
T z() const
Definition: PV3DBase.h:61
const std::string metname
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
static bool isFront(int station, int ring, int chamber)
static int maxStationId()
Definition: CSCDetId.h:237
assert(be >=bs)
static int maxRingId()
Definition: CSCDetId.h:239
#define LogTrace(id)
static int minChamberId()
Definition: CSCDetId.h:240
static MuDetRing * makeDetRing(std::vector< const GeomDet *> &geomDets)
static std::pair< std::vector< DetLayer * >, std::vector< DetLayer * > > buildLayers(const CSCGeometry &geo)
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr, const Compare &comp)
static int maxChamberId()
Definition: CSCDetId.h:241
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:43
static MuRingForwardDoubleLayer * buildLayer(int endcap, int station, std::vector< int > &rings, const CSCGeometry &geo)
const GeomDet * idToDet(DetId) const override
Definition: CSCGeometry.cc:91