File indexing completed on 2023-03-17 11:20:22
0001 #include <RecoMuon/DetLayers/src/MuonGEMDetLayerGeometryBuilder.h>
0002
0003 #include <DataFormats/MuonDetId/interface/GEMDetId.h>
0004 #include <Geometry/CommonDetUnit/interface/GeomDet.h>
0005 #include <RecoMuon/DetLayers/interface/MuRingForwardDoubleLayer.h>
0006 #include <RecoMuon/DetLayers/interface/MuRodBarrelLayer.h>
0007 #include <RecoMuon/DetLayers/interface/MuDetRing.h>
0008 #include <RecoMuon/DetLayers/interface/MuDetRod.h>
0009
0010 #include <Utilities/General/interface/precomputed_value_sort.h>
0011 #include <Geometry/CommonDetUnit/interface/DetSorting.h>
0012
0013 #include <FWCore/MessageLogger/interface/MessageLogger.h>
0014
0015 #include <iostream>
0016
0017 using namespace std;
0018
0019 MuonGEMDetLayerGeometryBuilder::~MuonGEMDetLayerGeometryBuilder() {}
0020
0021
0022
0023 pair<vector<DetLayer*>, vector<DetLayer*> > MuonGEMDetLayerGeometryBuilder::buildEndcapLayers(const GEMGeometry& geo) {
0024 vector<DetLayer*> endcapLayers[2];
0025
0026 const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuonGEMDetLayerGeometryBuilder";
0027 for (auto st : geo.stations()) {
0028 const int maxLayerId = (st->station() == GEMDetId::minStationId0) ? GEMDetId::maxLayerId0 : GEMDetId::maxLayerId;
0029 for (int layer = GEMDetId::minLayerId + 1; layer <= maxLayerId; ++layer) {
0030 ForwardDetLayer* forwardLayer = nullptr;
0031 vector<const ForwardDetRing*> frontRings, backRings;
0032
0033 for (int roll = GEMDetId::minRollId + 1; roll <= GEMDetId::maxRollId; ++roll) {
0034 vector<const GeomDet*> frontDets, backDets;
0035
0036 for (auto sc : st->superChambers()) {
0037 auto ch = sc->chamber(layer);
0038 if (ch == nullptr)
0039 continue;
0040
0041 auto etaP = ch->etaPartition(roll);
0042 if (etaP == nullptr)
0043 continue;
0044
0045 bool isInFront = isFront(etaP->id());
0046 if (isInFront) {
0047 frontDets.push_back(etaP);
0048 } else {
0049 backDets.push_back(etaP);
0050 }
0051 }
0052
0053 if (!frontDets.empty()) {
0054 precomputed_value_sort(frontDets.begin(), frontDets.end(), geomsort::DetPhi());
0055 frontRings.push_back(new MuDetRing(frontDets));
0056 LogTrace(metname) << "New front ring with " << frontDets.size()
0057 << " chambers at z=" << frontRings.back()->position().z();
0058 }
0059 if (!backDets.empty()) {
0060 precomputed_value_sort(backDets.begin(), backDets.end(), geomsort::DetPhi());
0061 backRings.push_back(new MuDetRing(backDets));
0062 LogTrace(metname) << "New back ring with " << backDets.size()
0063 << " chambers at z=" << backRings.back()->position().z();
0064 }
0065 }
0066
0067 if (!frontRings.empty()) {
0068 if (st->station() == GEMDetId::minStationId0)
0069 forwardLayer = new MuRingForwardLayer(frontRings);
0070 else if (!backRings.empty())
0071 forwardLayer = new MuRingForwardDoubleLayer(frontRings, backRings);
0072 }
0073
0074 if (forwardLayer != nullptr) {
0075 LogTrace(metname) << "New MuRingForwardLayer with " << frontRings.size() << " and " << backRings.size()
0076 << " rings, at Z " << forwardLayer->position().z()
0077 << " R1: " << forwardLayer->specificSurface().innerRadius()
0078 << " R2: " << forwardLayer->specificSurface().outerRadius();
0079
0080 int iendcap = (st->region() == 1) ? 0 : 1;
0081 endcapLayers[iendcap].push_back(forwardLayer);
0082 }
0083 }
0084 }
0085
0086 pair<vector<DetLayer*>, vector<DetLayer*> > res_pair(endcapLayers[0], endcapLayers[1]);
0087 return res_pair;
0088 }
0089
0090 bool MuonGEMDetLayerGeometryBuilder::isFront(const GEMDetId& gemId) {
0091
0092 if (gemId.station() == GEMDetId::minStationId0)
0093 return true;
0094
0095 return (gemId.chamber() % 2 == 0);
0096 }
0097
0098 MuDetRing* MuonGEMDetLayerGeometryBuilder::makeDetRing(vector<const GeomDet*>& geomDets) {
0099 const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuonGEMDetLayerGeometryBuilder";
0100
0101 precomputed_value_sort(geomDets.begin(), geomDets.end(), geomsort::DetPhi());
0102 MuDetRing* result = new MuDetRing(geomDets);
0103 LogTrace(metname) << "New MuDetRing with " << geomDets.size() << " chambers at z=" << result->position().z()
0104 << " R1: " << result->specificSurface().innerRadius()
0105 << " R2: " << result->specificSurface().outerRadius();
0106 return result;
0107 }