Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:25:45

0001 #include <RecoMuon/DetLayers/src/MuonME0DetLayerGeometryBuilder.h>
0002 
0003 #include <DataFormats/MuonDetId/interface/ME0DetId.h>
0004 #include <Geometry/CommonDetUnit/interface/GeomDet.h>
0005 //#include <RecoMuon/DetLayers/interface/MuRingForwardDoubleLayer.h>
0006 #include "RecoMuon/DetLayers/interface/MuRingForwardLayer.h"
0007 #include "RecoMuon/DetLayers/interface/MuRodBarrelLayer.h"
0008 #include "RecoMuon/DetLayers/interface/MuDetRing.h"
0009 #include "RecoMuon/DetLayers/interface/MuDetRod.h"
0010 
0011 #include "Utilities/General/interface/precomputed_value_sort.h"
0012 #include "Geometry/CommonDetUnit/interface/DetSorting.h"
0013 #include "Utilities/BinningTools/interface/ClusterizingHistogram.h"
0014 
0015 #include <FWCore/MessageLogger/interface/MessageLogger.h>
0016 
0017 #include <iostream>
0018 
0019 using namespace std;
0020 
0021 MuonME0DetLayerGeometryBuilder::~MuonME0DetLayerGeometryBuilder() {}
0022 
0023 // Builds the forward (first) and backward (second) layers - NOTE: Currently just one layer, all 'front'
0024 // Builds chambers (for segments) only, me0RecHits not used in track finding
0025 pair<vector<DetLayer*>, vector<DetLayer*> > MuonME0DetLayerGeometryBuilder::buildEndcapLayers(const ME0Geometry& geo) {
0026   vector<DetLayer*> result[2];
0027   const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuonME0DetLayerGeometryBuilder";
0028   LogTrace(metname) << "Starting endcaplayers ";
0029   for (int endcap = -1; endcap <= 1; endcap += 2) {
0030     int iendcap = (endcap == 1) ? 0 : 1;  // +1: forward, -1: backward
0031     int layer = 0;                        // only need to make layer 0 for segments
0032     vector<int> rolls, chambers;
0033     rolls.push_back(0);
0034     for (int chamber = ME0DetId::minChamberId + 1; chamber <= ME0DetId::maxChamberId; chamber++)
0035       chambers.push_back(chamber);
0036 
0037     LogTrace(metname) << "Encap =  " << endcap << "Chambers =  " << chambers.size() << "Rolls =  " << rolls.size();
0038     MuRingForwardLayer* ringLayer = buildLayer(endcap, layer, chambers, rolls, geo);
0039 
0040     if (ringLayer)
0041       result[iendcap].push_back(ringLayer);
0042   }
0043   pair<vector<DetLayer*>, vector<DetLayer*> > res_pair(result[0], result[1]);
0044 
0045   return res_pair;
0046 }
0047 
0048 MuRingForwardLayer* MuonME0DetLayerGeometryBuilder::buildLayer(
0049     int endcap, int layer, vector<int>& chambers, vector<int>& rolls, const ME0Geometry& geo) {
0050   const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuonME0DetLayerGeometryBuilder";
0051   MuRingForwardLayer* result = nullptr;
0052   vector<const ForwardDetRing*> frontRings, backRings;
0053 
0054   LogTrace(metname) << "Starting to Build Layer ";
0055 
0056   for (vector<int>::iterator roll = rolls.begin(); roll != rolls.end(); roll++) {
0057     LogTrace(metname) << "On a roll ";
0058 
0059     vector<const GeomDet*> frontDets, backDets;
0060 
0061     for (std::vector<int>::iterator chamber = chambers.begin(); chamber < chambers.end(); chamber++) {
0062       ME0DetId me0Id(endcap, layer, (*chamber), (*roll));
0063       const GeomDet* geomDet = geo.idToDet(me0Id);
0064 
0065       if (geomDet != nullptr) {
0066         bool isInFront = isFront(me0Id);
0067         if (isInFront) {
0068           frontDets.push_back(geomDet);
0069         } else {
0070           backDets.push_back(geomDet);
0071         }
0072       }
0073     }
0074 
0075     if (!frontDets.empty()) {
0076       precomputed_value_sort(frontDets.begin(), frontDets.end(), geomsort::DetPhi());
0077       frontRings.push_back(new MuDetRing(frontDets));
0078       LogTrace(metname) << "New front ring with " << frontDets.size()
0079                         << " chambers at z=" << frontRings.back()->position().z();
0080     }
0081     if (!backDets.empty()) {
0082       precomputed_value_sort(backDets.begin(), backDets.end(), geomsort::DetPhi());
0083       backRings.push_back(new MuDetRing(backDets));
0084       LogTrace(metname) << "New back ring with " << backDets.size()
0085                         << " chambers at z=" << backRings.back()->position().z();
0086     }
0087   }
0088 
0089   LogTrace(metname) << "About to make a MuRingForwardLayer";
0090   if (!frontRings.empty())
0091     result = new MuRingForwardLayer(frontRings);
0092   else
0093     result = nullptr;
0094   if (result != nullptr) {
0095     LogTrace(metname) << "New MuRingForwardLayer with " << frontRings.size() << " and " << backRings.size()
0096                       << " rings, at Z " << result->position().z() << " R1: " << result->specificSurface().innerRadius()
0097                       << " R2: " << result->specificSurface().outerRadius();
0098   }
0099   return result;
0100 }
0101 
0102 bool MuonME0DetLayerGeometryBuilder::isFront(const ME0DetId& me0Id) {
0103   //ME0s do not currently have an arrangement of which are front and which are back, going to always return true
0104 
0105   bool result = true;
0106   return result;
0107 }
0108 
0109 MuDetRing* MuonME0DetLayerGeometryBuilder::makeDetRing(vector<const GeomDet*>& geomDets) {
0110   const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuonME0DetLayerGeometryBuilder";
0111 
0112   precomputed_value_sort(geomDets.begin(), geomDets.end(), geomsort::DetPhi());
0113   MuDetRing* result = new MuDetRing(geomDets);
0114   LogTrace(metname) << "New MuDetRing with " << geomDets.size() << " chambers at z=" << result->position().z()
0115                     << " R1: " << result->specificSurface().innerRadius()
0116                     << " R2: " << result->specificSurface().outerRadius();
0117   return result;
0118 }