CMS 3D CMS Logo

MuonGEMDetLayerGeometryBuilder.cc
Go to the documentation of this file.
2 
9 
13 
15 
16 #include <iostream>
17 
18 using namespace std;
19 
21 }
22 
23 // Builds the forward (first) and backward (second) layers
24 // Builds etaPartitions (for rechits)
25 pair<vector<DetLayer*>, vector<DetLayer*> >
27 
28  vector<DetLayer*> result[2];
29 
30  for (int endcap = -1; endcap<=1; endcap+=2) {
31  int iendcap = (endcap==1) ? 0 : 1; // +1: forward, -1: backward
32 
34  for(int layer = GEMDetId::minLayerId+1; layer <= GEMDetId::maxLayerId; ++layer) {
35 
36  vector<int> rolls, rings, chambers;
37  for(int ring = GEMDetId::minRingId; ring <= GEMDetId::maxRingId; ++ring) rings.push_back(ring);
39  chambers.push_back(chamber);
40  for(int roll = GEMDetId::minRollId+1; roll <= GEMDetId::maxRollId; ++roll)
41  rolls.push_back(roll);
42 
43  MuRingForwardDoubleLayer* ringLayer = buildLayer(endcap, rings, station, layer, chambers, rolls, geo);
44 
45  if (ringLayer) result[iendcap].push_back(ringLayer);
46  }
47  }
48  }
49  pair<vector<DetLayer*>, vector<DetLayer*> > res_pair(result[0], result[1]);
50 
51  return res_pair;
52 }
53 
56  int layer,
57  vector<int>& chambers,
58  vector<int>& rolls,
59  const GEMGeometry& geo) {
60 
61  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuonGEMDetLayerGeometryBuilder";
63  vector<const ForwardDetRing*> frontRings, backRings;
64 
65 
66  for (std::vector<int>::iterator ring=rings.begin(); ring!=rings.end()-2;ring++){
67 
68  for (vector<int>::iterator roll = rolls.begin(); roll!=rolls.end(); roll++) {
69 
70  vector<const GeomDet*> frontDets, backDets;
71 
72  for(std::vector<int>::iterator chamber=chambers.begin(); chamber<chambers.end(); chamber++) {
73  GEMDetId gemId(endcap,(*ring), station,layer,(*chamber), (*roll));
74 
75  const GeomDet* geomDet = geo.idToDet(gemId);
76 
77  if (geomDet !=0) {
78  bool isInFront = isFront(gemId);
79  if(isInFront)
80  {
81  frontDets.push_back(geomDet);
82  }
83  else
84  {
85  backDets.push_back(geomDet);
86  }
87  LogTrace(metname) << "get GEM Endcap roll "
88  << gemId
89  << (isInFront ? "front" : "back ")
90  << " at R=" << geomDet->position().perp()
91  << ", phi=" << geomDet->position().phi()
92  << ", Z=" << geomDet->position().z();
93  }
94  }
95 
96  if (frontDets.size()!=0) {
97  precomputed_value_sort(frontDets.begin(), frontDets.end(), geomsort::DetPhi());
98  frontRings.push_back(new MuDetRing(frontDets));
99  LogTrace(metname) << "New front ring with " << frontDets.size()
100  << " chambers at z="<< frontRings.back()->position().z();
101  }
102  if (backDets.size()!=0) {
103  precomputed_value_sort(backDets.begin(), backDets.end(), geomsort::DetPhi());
104  backRings.push_back(new MuDetRing(backDets));
105  LogTrace(metname) << "New back ring with " << backDets.size()
106  << " chambers at z="<< backRings.back()->position().z();
107  }
108 
109  }
110 
111  }
112 
113  // How should they be sorted?
114  // precomputed_value_sort(muDetRods.begin(), muDetRods.end(), geomsort::ExtractZ<GeometricSearchDet,float>());
115  if(backRings.size()!=0 && frontRings.size()!=0) result = new MuRingForwardDoubleLayer(frontRings, backRings);
116  else result = 0;
117  if(result != 0){
118  LogTrace(metname) << "New MuRingForwardLayer with " << frontRings.size()
119  << " and " << backRings.size()
120  << " rings, at Z " << result->position().z()
121  << " R1: " << result->specificSurface().innerRadius()
122  << " R2: " << result->specificSurface().outerRadius();
123  }
124  return result;
125 
126 }
127 
128 
130 {
131 
132  bool result = false;
133  int chamber = gemId.chamber();
134 
135  if(chamber%2 == 0) result = !result;
136 
137  return result;
138 }
139 
140 MuDetRing * MuonGEMDetLayerGeometryBuilder::makeDetRing(vector<const GeomDet*> & geomDets)
141 {
142  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuonGEMDetLayerGeometryBuilder";
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 }
ExtractPhi< GeomDet, float > DetPhi
Definition: DetSorting.h:39
T perp() const
Definition: PV3DBase.h:72
static const int minRingId
Definition: GEMDetId.h:97
const std::string metname
static const int minChamberId
Definition: GEMDetId.h:103
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
static const int maxRollId
Definition: GEMDetId.h:111
int chamber() const
Chamber id: it identifies a chamber in a ring it goes from 1 to 36.
Definition: GEMDetId.h:74
static const int maxChamberId
Definition: GEMDetId.h:104
static const int maxLayerId
Definition: GEMDetId.h:108
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:48
T z() const
Definition: PV3DBase.h:64
static const int minRollId
Definition: GEMDetId.h:110
static const int maxStationId
Definition: GEMDetId.h:101
static bool isFront(const GEMDetId &gemId)
#define LogTrace(id)
const GeomDet * idToDet(DetId) const override
Definition: GEMGeometry.cc:38
static const int minStationId
Definition: GEMDetId.h:100
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr)
static const int maxRingId
Definition: GEMDetId.h:98
static const int minLayerId
Definition: GEMDetId.h:107
static char chambers[264][20]
Definition: ReadPGInfo.cc:243
static MuDetRing * makeDetRing(std::vector< const GeomDet * > &geomDets)
static std::pair< std::vector< DetLayer * >, std::vector< DetLayer * > > buildEndcapLayers(const GEMGeometry &geo)
static MuRingForwardDoubleLayer * buildLayer(int endcap, std::vector< int > &rings, int station, int layer, std::vector< int > &chambers, std::vector< int > &rolls, const GEMGeometry &geo)