Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /** \file
0002  *
0003  *  \author N. Amapane - CERN
0004  *
0005  *  \modified by R. Radogna & C. Calabria & A. Sharma
0006  *  \modified by D. Nash
0007  */
0008 
0009 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0010 #include "RecoMuon/DetLayers/interface/MuonDetLayerGeometry.h"
0011 
0012 #include "Geometry/DTGeometry/interface/DTGeometry.h"
0013 #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
0014 #include "Geometry/RPCGeometry/interface/RPCGeometry.h"
0015 #include "Geometry/GEMGeometry/interface/GEMGeometry.h"
0016 #include "Geometry/GEMGeometry/interface/ME0Geometry.h"
0017 
0018 #include "RecoMuon/Records/interface/MuonRecoGeometryRecord.h"
0019 #include "RecoMuon/DetLayers/src/MuonCSCDetLayerGeometryBuilder.h"
0020 #include "RecoMuon/DetLayers/src/MuonRPCDetLayerGeometryBuilder.h"
0021 #include "RecoMuon/DetLayers/src/MuonDTDetLayerGeometryBuilder.h"
0022 #include "RecoMuon/DetLayers/src/MuonGEMDetLayerGeometryBuilder.h"
0023 #include "RecoMuon/DetLayers/src/MuonME0DetLayerGeometryBuilder.h"
0024 
0025 #include "FWCore/Framework/interface/EventSetup.h"
0026 #include "FWCore/Framework/interface/ESHandle.h"
0027 #include "FWCore/Framework/interface/ESProducer.h"
0028 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0029 #include "FWCore/Framework/interface/ModuleFactory.h"
0030 
0031 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0032 #include "FWCore/Framework/interface/NoProxyException.h"
0033 
0034 #include <memory>
0035 
0036 class MuonDetLayerGeometryESProducer : public edm::ESProducer {
0037 public:
0038   /// Constructor
0039   MuonDetLayerGeometryESProducer(const edm::ParameterSet& p);
0040 
0041   /// Produce MuonDeLayerGeometry.
0042   std::unique_ptr<MuonDetLayerGeometry> produce(const MuonRecoGeometryRecord& record);
0043 
0044   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0045 
0046 private:
0047   edm::ESGetToken<DTGeometry, MuonGeometryRecord> dtToken_;
0048   edm::ESGetToken<CSCGeometry, MuonGeometryRecord> cscToken_;
0049   edm::ESGetToken<GEMGeometry, MuonGeometryRecord> gemToken_;
0050   edm::ESGetToken<ME0Geometry, MuonGeometryRecord> me0Token_;
0051   edm::ESGetToken<RPCGeometry, MuonGeometryRecord> rpcToken_;
0052 };
0053 
0054 using namespace edm;
0055 
0056 MuonDetLayerGeometryESProducer::MuonDetLayerGeometryESProducer(const edm::ParameterSet& p) {
0057   auto cc = setWhatProduced(this);
0058   dtToken_ = cc.consumes();
0059   cscToken_ = cc.consumes();
0060   gemToken_ = cc.consumes();
0061   me0Token_ = cc.consumes();
0062   rpcToken_ = cc.consumes();
0063 }
0064 
0065 std::unique_ptr<MuonDetLayerGeometry> MuonDetLayerGeometryESProducer::produce(const MuonRecoGeometryRecord& record) {
0066   const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuonDetLayerGeometryESProducer";
0067   auto muonDetLayerGeometry = std::make_unique<MuonDetLayerGeometry>();
0068 
0069   // Build DT layers
0070   if (auto dt = record.getHandle(dtToken_)) {
0071     muonDetLayerGeometry->addDTLayers(MuonDTDetLayerGeometryBuilder::buildLayers(*dt));
0072   } else {
0073     LogInfo(metname) << "No DT geometry is available.";
0074   }
0075 
0076   // Build CSC layers
0077   if (auto csc = record.getHandle(cscToken_)) {
0078     muonDetLayerGeometry->addCSCLayers(MuonCSCDetLayerGeometryBuilder::buildLayers(*csc));
0079   } else {
0080     LogInfo(metname) << "No CSC geometry is available.";
0081   }
0082 
0083   // Build GEM layers
0084   if (auto gem = record.getHandle(gemToken_)) {
0085     muonDetLayerGeometry->addGEMLayers(MuonGEMDetLayerGeometryBuilder::buildEndcapLayers(*gem));
0086   } else {
0087     LogInfo(metname) << "No GEM geometry is available.";
0088   }
0089 
0090   // Build ME0 layers
0091   if (auto me0 = record.getHandle(me0Token_)) {
0092     muonDetLayerGeometry->addME0Layers(MuonME0DetLayerGeometryBuilder::buildEndcapLayers(*me0));
0093   } else {
0094     LogDebug(metname) << "No ME0 geometry is available.";
0095   }
0096 
0097   // Build RPC layers
0098   if (auto rpc = record.getHandle(rpcToken_)) {
0099     muonDetLayerGeometry->addRPCLayers(MuonRPCDetLayerGeometryBuilder::buildBarrelLayers(*rpc),
0100                                        MuonRPCDetLayerGeometryBuilder::buildEndcapLayers(*rpc));
0101   } else {
0102     LogInfo(metname) << "No RPC geometry is available.";
0103   }
0104 
0105   // Sort layers properly
0106   muonDetLayerGeometry->sortLayers();
0107 
0108   return muonDetLayerGeometry;
0109 }
0110 
0111 void MuonDetLayerGeometryESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0112   edm::ParameterSetDescription desc;
0113   //no parameters are used
0114   descriptions.addDefault(desc);
0115 }
0116 
0117 DEFINE_FWK_EVENTSETUP_MODULE(MuonDetLayerGeometryESProducer);