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 // Builds the forward (first) and backward (second) layers
23 // Builds etaPartitions (for rechits)
24 pair<vector<DetLayer*>, vector<DetLayer*> > MuonGEMDetLayerGeometryBuilder::buildEndcapLayers(const GEMGeometry& geo) {
25  vector<DetLayer*> result[2];
26 
27  for (int endcap = -1; endcap <= 1; endcap += 2) {
28  int iendcap = (endcap == 1) ? 0 : 1; // +1: forward, -1: backward
29 
31  for (int layer = GEMDetId::minLayerId + 1; layer <= GEMDetId::maxLayerId; ++layer) {
32  vector<int> rolls, rings, chambers;
34  rings.push_back(ring);
36  chambers.push_back(chamber);
37  for (int roll = GEMDetId::minRollId + 1; roll <= GEMDetId::maxRollId; ++roll)
38  rolls.push_back(roll);
39 
40  MuRingForwardDoubleLayer* ringLayer = buildLayer(endcap, rings, station, layer, chambers, rolls, geo);
41 
42  if (ringLayer)
43  result[iendcap].push_back(ringLayer);
44  }
45  }
46  }
47  pair<vector<DetLayer*>, vector<DetLayer*> > res_pair(result[0], result[1]);
48 
49  return res_pair;
50 }
51 
53  vector<int>& rings,
54  int station,
55  int layer,
56  vector<int>& chambers,
57  vector<int>& rolls,
58  const GEMGeometry& geo) {
59  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuonGEMDetLayerGeometryBuilder";
61  vector<const ForwardDetRing*> frontRings, backRings;
62 
63  for (std::vector<int>::iterator ring = rings.begin(); ring != rings.end() - 2; ring++) {
64  for (vector<int>::iterator roll = rolls.begin(); roll != rolls.end(); roll++) {
65  vector<const GeomDet*> frontDets, backDets;
66 
67  for (std::vector<int>::iterator chamber = chambers.begin(); chamber < chambers.end(); chamber++) {
68  GEMDetId gemId(endcap, (*ring), station, layer, (*chamber), (*roll));
69 
70  const GeomDet* geomDet = geo.idToDet(gemId);
71 
72  if (geomDet != nullptr) {
73  bool isInFront = isFront(gemId);
74  if (isInFront) {
75  frontDets.push_back(geomDet);
76  } else {
77  backDets.push_back(geomDet);
78  }
79  LogTrace(metname) << "get GEM Endcap roll " << gemId << (isInFront ? "front" : "back ")
80  << " at R=" << geomDet->position().perp() << ", phi=" << geomDet->position().phi()
81  << ", Z=" << geomDet->position().z();
82  }
83  }
84 
85  if (!frontDets.empty()) {
86  precomputed_value_sort(frontDets.begin(), frontDets.end(), geomsort::DetPhi());
87  frontRings.push_back(new MuDetRing(frontDets));
88  LogTrace(metname) << "New front ring with " << frontDets.size()
89  << " chambers at z=" << frontRings.back()->position().z();
90  }
91  if (!backDets.empty()) {
92  precomputed_value_sort(backDets.begin(), backDets.end(), geomsort::DetPhi());
93  backRings.push_back(new MuDetRing(backDets));
94  LogTrace(metname) << "New back ring with " << backDets.size()
95  << " chambers at z=" << backRings.back()->position().z();
96  }
97  }
98  }
99 
100  // How should they be sorted?
101  // precomputed_value_sort(muDetRods.begin(), muDetRods.end(), geomsort::ExtractZ<GeometricSearchDet,float>());
102  if (!backRings.empty() && !frontRings.empty())
103  result = new MuRingForwardDoubleLayer(frontRings, backRings);
104  else
105  result = nullptr;
106  if (result != nullptr) {
107  LogTrace(metname) << "New MuRingForwardLayer with " << frontRings.size() << " and " << backRings.size()
108  << " rings, at Z " << result->position().z() << " R1: " << result->specificSurface().innerRadius()
109  << " R2: " << result->specificSurface().outerRadius();
110  }
111  return result;
112 }
113 
115  bool result = false;
116  int chamber = gemId.chamber();
117 
118  if (chamber % 2 == 0)
119  result = !result;
120 
121  return result;
122 }
123 
124 MuDetRing* MuonGEMDetLayerGeometryBuilder::makeDetRing(vector<const GeomDet*>& geomDets) {
125  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuonGEMDetLayerGeometryBuilder";
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 }
GeomDet::position
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:43
MuonGEMDetLayerGeometryBuilder.h
MessageLogger.h
MuRingForwardDoubleLayer.h
GeomDet
Definition: GeomDet.h:27
GEMGeometry::idToDet
const GeomDet * idToDet(DetId) const override
Definition: GEMGeometry.cc:25
relativeConstraints.station
station
Definition: relativeConstraints.py:67
MuonGEMDetLayerGeometryBuilder::isFront
static bool isFront(const GEMDetId &gemId)
Definition: MuonGEMDetLayerGeometryBuilder.cc:114
GEMDetId::maxStationId
static constexpr int32_t maxStationId
Definition: GEMDetId.h:26
GEMDetId::minChamberId
static constexpr int32_t minChamberId
Definition: GEMDetId.h:27
MuonGEMDetLayerGeometryBuilder::~MuonGEMDetLayerGeometryBuilder
virtual ~MuonGEMDetLayerGeometryBuilder()
Destructor.
Definition: MuonGEMDetLayerGeometryBuilder.cc:20
GEMDetId::minLayerId
static constexpr int32_t minLayerId
Definition: GEMDetId.h:29
makeMuonMisalignmentScenario.endcap
endcap
Definition: makeMuonMisalignmentScenario.py:320
precomputed_value_sort.h
MuDetRing
Definition: MuDetRing.h:16
GEMDetId::maxRollId
static constexpr int32_t maxRollId
Definition: GEMDetId.h:33
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
DetSorting.h
geomsort::DetPhi
ExtractPhi< GeomDet, float > DetPhi
Definition: DetSorting.h:37
GEMDetId::maxRingId
static constexpr int32_t maxRingId
Definition: GEMDetId.h:22
GEMDetId::maxChamberId
static constexpr int32_t maxChamberId
Definition: GEMDetId.h:28
GEMDetId::minRingId
static constexpr int32_t minRingId
Definition: GEMDetId.h:21
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
GEMDetId::chamber
constexpr int chamber() const
Definition: GEMDetId.h:177
GEMDetId
Definition: GEMDetId.h:17
MuonGEMDetLayerGeometryBuilder::buildEndcapLayers
static std::pair< std::vector< DetLayer * >, std::vector< DetLayer * > > buildEndcapLayers(const GEMGeometry &geo)
Definition: MuonGEMDetLayerGeometryBuilder.cc:24
chambers
static char chambers[264][20]
Definition: ReadPGInfo.cc:243
MuonGEMDetLayerGeometryBuilder::buildLayer
static MuRingForwardDoubleLayer * buildLayer(int endcap, std::vector< int > &rings, int station, int layer, std::vector< int > &chambers, std::vector< int > &rolls, const GEMGeometry &geo)
Definition: MuonGEMDetLayerGeometryBuilder.cc:52
MuonGEMDetLayerGeometryBuilder::makeDetRing
static MuDetRing * makeDetRing(std::vector< const GeomDet * > &geomDets)
Definition: MuonGEMDetLayerGeometryBuilder.cc:124
GeomDet.h
GEMDetId.h
std
Definition: JetResolutionObject.h:76
GEMDetId::maxLayerId
static constexpr int32_t maxLayerId
Definition: GEMDetId.h:31
ClusterizingHistogram.h
relativeConstraints.ring
ring
Definition: relativeConstraints.py:68
MuRodBarrelLayer.h
MuDetRing.h
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
GEMDetId::minRollId
static constexpr int32_t minRollId
Definition: GEMDetId.h:32
GEMGeometry
Definition: GEMGeometry.h:24
GEMDetId::minStationId
static constexpr int32_t minStationId
Definition: GEMDetId.h:24
mps_fire.result
result
Definition: mps_fire.py:303
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
precomputed_value_sort
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr, const Compare &comp)
Definition: precomputed_value_sort.h:17
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
MuRingForwardDoubleLayer
Definition: MuRingForwardDoubleLayer.h:19
metname
const std::string metname
Definition: MuonSeedOrcaPatternRecognition.cc:43
MuDetRod.h