Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 10:01:09

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 
0033 #include <memory>
0034 
0035 class MuonDetLayerGeometryESProducer : public edm::ESProducer {
0036 public:
0037   /// Constructor
0038   MuonDetLayerGeometryESProducer(const edm::ParameterSet& p);
0039 
0040   /// Produce MuonDeLayerGeometry.
0041   std::unique_ptr<MuonDetLayerGeometry> produce(const MuonRecoGeometryRecord& record);
0042 
0043   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0044 
0045 private:
0046   edm::ESGetToken<DTGeometry, MuonGeometryRecord> dtToken_;
0047   edm::ESGetToken<CSCGeometry, MuonGeometryRecord> cscToken_;
0048   edm::ESGetToken<GEMGeometry, MuonGeometryRecord> gemToken_;
0049   edm::ESGetToken<ME0Geometry, MuonGeometryRecord> me0Token_;
0050   edm::ESGetToken<RPCGeometry, MuonGeometryRecord> rpcToken_;
0051 };
0052 
0053 using namespace edm;
0054 
0055 MuonDetLayerGeometryESProducer::MuonDetLayerGeometryESProducer(const edm::ParameterSet& p) {
0056   auto cc = setWhatProduced(this);
0057   dtToken_ = cc.consumes();
0058   cscToken_ = cc.consumes();
0059   gemToken_ = cc.consumes();
0060   me0Token_ = cc.consumes();
0061   rpcToken_ = cc.consumes();
0062 }
0063 
0064 std::unique_ptr<MuonDetLayerGeometry> MuonDetLayerGeometryESProducer::produce(const MuonRecoGeometryRecord& record) {
0065   const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuonDetLayerGeometryESProducer";
0066   auto muonDetLayerGeometry = std::make_unique<MuonDetLayerGeometry>();
0067 
0068   // Build DT layers
0069   if (auto dt = record.getHandle(dtToken_)) {
0070     muonDetLayerGeometry->addDTLayers(MuonDTDetLayerGeometryBuilder::buildLayers(*dt));
0071   } else {
0072     LogInfo(metname) << "No DT geometry is available.";
0073   }
0074 
0075   // Build CSC layers
0076   if (auto csc = record.getHandle(cscToken_)) {
0077     muonDetLayerGeometry->addCSCLayers(MuonCSCDetLayerGeometryBuilder::buildLayers(*csc));
0078   } else {
0079     LogInfo(metname) << "No CSC geometry is available.";
0080   }
0081 
0082   // Build GEM layers
0083   if (auto gem = record.getHandle(gemToken_)) {
0084     muonDetLayerGeometry->addGEMLayers(MuonGEMDetLayerGeometryBuilder::buildEndcapLayers(*gem));
0085   } else {
0086     LogInfo(metname) << "No GEM geometry is available.";
0087   }
0088 
0089   // Build ME0 layers
0090   if (auto me0 = record.getHandle(me0Token_)) {
0091     muonDetLayerGeometry->addME0Layers(MuonME0DetLayerGeometryBuilder::buildEndcapLayers(*me0));
0092   } else {
0093     LogDebug(metname) << "No ME0 geometry is available.";
0094   }
0095 
0096   // Build RPC layers
0097   if (auto rpc = record.getHandle(rpcToken_)) {
0098     muonDetLayerGeometry->addRPCLayers(MuonRPCDetLayerGeometryBuilder::buildBarrelLayers(*rpc),
0099                                        MuonRPCDetLayerGeometryBuilder::buildEndcapLayers(*rpc));
0100   } else {
0101     LogInfo(metname) << "No RPC geometry is available.";
0102   }
0103 
0104   // Sort layers properly
0105   muonDetLayerGeometry->sortLayers();
0106 
0107   return muonDetLayerGeometry;
0108 }
0109 
0110 void MuonDetLayerGeometryESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0111   edm::ParameterSetDescription desc;
0112   //no parameters are used
0113   descriptions.addDefault(desc);
0114 }
0115 
0116 DEFINE_FWK_EVENTSETUP_MODULE(MuonDetLayerGeometryESProducer);