CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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*> >
19 
20  vector<DetLayer*> result[2]; // one for each endcap
21 
22  for(int i=0; i<2; i++) {
23 
24  int endcap = i+1;
25 
26  // ME/1/1a (= station 1, ring 4) and ME/1/1b (= station 1, ring 1)
27  {
28  vector<int> rings;
29  rings.push_back(4);
30  rings.push_back(1);
31 
32  MuRingForwardDoubleLayer* layer = buildLayer(endcap, 1, rings, geo);
33  if (layer) result[i].push_back(layer);
34  }
35 
36  // ME/1/2 and 1/3 (= station 1, ring 2 and 3)
37  {
38  vector<int> rings;
39  rings.push_back(2);
40  rings.push_back(3);
41 
42  MuRingForwardDoubleLayer* layer = buildLayer(endcap, 1, rings, geo);
43  if (layer) result[i].push_back(layer);
44  }
45 
46  // Stations 2,3,4
47  for(int station = 2; station <= CSCDetId::maxStationId(); station++) {
48  vector<int> rings;
49  for(int ring = CSCDetId::minRingId(); ring <= CSCDetId::maxRingId(); ring++) {
50  rings.push_back(ring);
51  }
52  MuRingForwardDoubleLayer* layer = buildLayer(endcap, station, rings, geo);
53  if (layer) 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;
71  for(int chamber = CSCDetId::minChamberId(); chamber <= CSCDetId::maxChamberId(); chamber++) {
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 != 0)
77  {
78  if(isInFront)
79  {
80  frontGeomDets.push_back(geomDet);
81  }
82  else
83  {
84  backGeomDets.push_back(geomDet);
85  }
86  LogTrace(metname) << "get CSC chamber "
87  << CSCDetId(endcap, station, (*ring), chamber, 0)
88  << " at R=" << geomDet->position().perp()
89  << ", phi=" << geomDet->position().phi()
90  << ", z= " << geomDet->position().z()
91  << " isFront? " << isInFront;
92  }
93  }
94 
95  if(!backGeomDets.empty())
96  {
97  backRings.push_back(makeDetRing(backGeomDets));
98  }
99 
100  if(!frontGeomDets.empty())
101  {
102  frontRings.push_back(makeDetRing(frontGeomDets));
103  assert(!backGeomDets.empty());
104  float frontz = frontRings[0]->position().z();
105  float backz = backRings[0]->position().z();
106  assert(fabs(frontz) < fabs(backz));
107  }
108  }
109 
110  // How should they be sorted?
111  // precomputed_value_sort(muDetRods.begin(), muDetRods.end(), geomsort::ExtractZ<GeometricSearchDet,float>());
112  result = new MuRingForwardDoubleLayer(frontRings, backRings);
113  LogTrace(metname) << "New MuRingForwardLayer with " << frontRings.size()
114  << " and " << backRings.size()
115  << " rings, at Z " << result->position().z()
116  << " R1: " << result->specificSurface().innerRadius()
117  << " R2: " << result->specificSurface().outerRadius();
118  return result;
119 }
120 
121 
123 {
124  bool result = false;
125 
126  bool isOverlapping = !(station == 1 && ring == 3);
127  // not overlapping means back
128  if(isOverlapping)
129  {
130  bool isEven = (chamber%2==0);
131  // odd chambers are bolted to the iron, which faces
132  // forward in 1&2, backward in 3&4, so...
133  result = (station<3) ? isEven : !isEven;
134  }
135  return result;
136 }
137 
138 
139 
140 MuDetRing * MuonCSCDetLayerGeometryBuilder::makeDetRing(vector<const GeomDet*> & geomDets)
141 {
142  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuonCSCDetLayerGeometryBuilder";
143 
144 
145  precomputed_value_sort(geomDets.begin(), geomDets.end(), geomsort::DetPhi());
146  MuDetRing * result = new MuDetRing(geomDets);
147  LogTrace(metname) << "New MuDetRing with " << geomDets.size()
148  << " chambers at z="<< result->position().z()
149  << " R1: " << result->specificSurface().innerRadius()
150  << " R2: " << result->specificSurface().outerRadius();
151  return result;
152 }
153 
int i
Definition: DBlmapReader.cc:9
static int minRingId()
Definition: CSCDetId.h:242
ExtractPhi< GeomDet, float > DetPhi
Definition: DetSorting.h:43
T perp() const
Definition: PV3DBase.h:71
const std::string metname
Geom::Phi< T > phi() const
Definition: PV3DBase.h:68
static bool isFront(int station, int ring, int chamber)
static int maxStationId()
Definition: CSCDetId.h:241
static int maxRingId()
Definition: CSCDetId.h:243
static int minChamberId()
Definition: CSCDetId.h:244
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:41
static std::pair< std::vector< DetLayer * >, std::vector< DetLayer * > > buildLayers(const CSCGeometry &geo)
T z() const
Definition: PV3DBase.h:63
tuple result
Definition: query.py:137
virtual const BoundDisk & specificSurface() const
#define LogTrace(id)
static MuDetRing * makeDetRing(std::vector< const GeomDet * > &geomDets)
static int maxChamberId()
Definition: CSCDetId.h:245
virtual const GeomDet * idToDet(DetId) const
Definition: CSCGeometry.cc:93
virtual const Surface::PositionType & position() const
Returns position of the surface.
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr)
float outerRadius() const
The outer radius of the disk.
Definition: BoundDisk.h:75
float innerRadius() const
The inner radius of the disk.
Definition: BoundDisk.h:72
static MuRingForwardDoubleLayer * buildLayer(int endcap, int station, std::vector< int > &rings, const CSCGeometry &geo)