test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonGEMDetLayerGeometryBuilder.cc
Go to the documentation of this file.
2 
9 
13 
15 
16 #include <iostream>
17 
18 using namespace std;
19 
20 //MuonGEMDetLayerGeometryBuilder::~MuonGEMDetLayerGeometryBuilder() {
21 //}
22 
23 
24 // Builds the forward (first) and backward (second) layers
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; layer <= GEMDetId::maxLayerId; ++layer) {
35  vector<int> rolls;
36  std::vector<int> rings;
37  std::vector<int> chambers;
39  rings.push_back(ring);
40  }
41  for(int roll = GEMDetId::minRollId+1; roll <= GEMDetId::maxRollId; ++roll) {
42  rolls.push_back(roll);
43  }
44  for(int chamber = GEMDetId::minChamberId; chamber <= GEMDetId::maxChamberId; chamber++ ){
45  chambers.push_back(chamber);
46  }
47 
48  MuRingForwardDoubleLayer* ringLayer = buildLayer(endcap, rings, station, layer, chambers, rolls, geo);
49 
50  if (ringLayer) result[iendcap].push_back(ringLayer);
51 
52  }
53 
54  }
55 
56 
57  }
58  pair<vector<DetLayer*>, vector<DetLayer*> > res_pair(result[0], result[1]);
59 
60  return res_pair;
61 
62 }
63 
64 
65 
68  int layer,
69  vector<int>& chambers,
70  vector<int>& rolls,
71  const GEMGeometry& geo) {
72 
73  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuonGEMDetLayerGeometryBuilder";
75  vector<const ForwardDetRing*> frontRings, backRings;
76 
77 
78  for (std::vector<int>::iterator ring=rings.begin(); ring!=rings.end()-2;ring++){
79 
80  for (vector<int>::iterator roll = rolls.begin(); roll!=rolls.end(); roll++) {
81 
82  vector<const GeomDet*> frontDets, backDets;
83 
84  for(std::vector<int>::iterator chamber=chambers.begin()+1; chamber<chambers.end(); chamber++) {
85  GEMDetId gemId(endcap,(*ring), station,layer,(*chamber), (*roll));
86 
87  const GeomDet* geomDet = geo.idToDet(gemId);
88 
89  if (geomDet !=0) {
90  bool isInFront = isFront(gemId);
91  if(isInFront)
92  {
93  frontDets.push_back(geomDet);
94  }
95  else
96  {
97  backDets.push_back(geomDet);
98  }
99  LogTrace(metname) << "get GEM Endcap roll "
100  << gemId
101  << (isInFront ? "front" : "back ")
102  << " at R=" << geomDet->position().perp()
103  << ", phi=" << geomDet->position().phi()
104  << ", Z=" << geomDet->position().z();
105  }
106  }
107 
108  if (frontDets.size()!=0) {
109  precomputed_value_sort(frontDets.begin(), frontDets.end(), geomsort::DetPhi());
110  frontRings.push_back(new MuDetRing(frontDets));
111  LogTrace(metname) << "New front ring with " << frontDets.size()
112  << " chambers at z="<< frontRings.back()->position().z();
113  }
114  if (backDets.size()!=0) {
115  precomputed_value_sort(backDets.begin(), backDets.end(), geomsort::DetPhi());
116  backRings.push_back(new MuDetRing(backDets));
117  LogTrace(metname) << "New back ring with " << backDets.size()
118  << " chambers at z="<< backRings.back()->position().z();
119  }
120 
121  }
122 
123  }
124 
125  // How should they be sorted?
126  // precomputed_value_sort(muDetRods.begin(), muDetRods.end(), geomsort::ExtractZ<GeometricSearchDet,float>());
127  if(backRings.size()!=0 && frontRings.size()!=0) result = new MuRingForwardDoubleLayer(frontRings, backRings);
128  else result = 0;
129  if(result != 0){
130  LogTrace(metname) << "New MuRingForwardLayer with " << frontRings.size()
131  << " and " << backRings.size()
132  << " rings, at Z " << result->position().z()
133  << " R1: " << result->specificSurface().innerRadius()
134  << " R2: " << result->specificSurface().outerRadius();
135  }
136  return result;
137 
138 }
139 
140 
142 {
143 
144  bool result = false;
145  int chamber = gemId.chamber();
146 
147  if(chamber%2 == 0) result = !result;
148 
149  return result;
150 }
151 
152 MuDetRing * MuonGEMDetLayerGeometryBuilder::makeDetRing(vector<const GeomDet*> & geomDets)
153 {
154  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuonGEMDetLayerGeometryBuilder";
155 
156 
157  precomputed_value_sort(geomDets.begin(), geomDets.end(), geomsort::DetPhi());
158  MuDetRing * result = new MuDetRing(geomDets);
159  LogTrace(metname) << "New MuDetRing with " << geomDets.size()
160  << " chambers at z="<< result->position().z()
161  << " R1: " << result->specificSurface().innerRadius()
162  << " R2: " << result->specificSurface().outerRadius();
163  return result;
164 }
ExtractPhi< GeomDet, float > DetPhi
Definition: DetSorting.h:39
T perp() const
Definition: PV3DBase.h:72
static const int minRingId
Definition: GEMDetId.h:93
const std::string metname
virtual const GeomDet * idToDet(DetId) const override
Definition: GEMGeometry.cc:38
static const int minChamberId
Definition: GEMDetId.h:99
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
static const int maxRollId
Definition: GEMDetId.h:106
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:100
static const int maxLayerId
Definition: GEMDetId.h:103
tuple result
Definition: mps_fire.py:84
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:105
static const int maxStationId
Definition: GEMDetId.h:97
static bool isFront(const GEMDetId &gemId)
#define LogTrace(id)
static const int minStationId
Definition: GEMDetId.h:96
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr)
static const int maxRingId
Definition: GEMDetId.h:94
static const int minLayerId
Definition: GEMDetId.h:102
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)