CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/RecoMuon/DetLayers/plugins/MuonDetLayerGeometryESProducer.cc

Go to the documentation of this file.
00001 
00008 #include <RecoMuon/DetLayers/plugins/MuonDetLayerGeometryESProducer.h>
00009 #include <Geometry/Records/interface/MuonGeometryRecord.h>
00010 
00011 #include <Geometry/DTGeometry/interface/DTGeometry.h>
00012 #include <Geometry/CSCGeometry/interface/CSCGeometry.h>
00013 #include <Geometry/RPCGeometry/interface/RPCGeometry.h>
00014 
00015 #include <RecoMuon/DetLayers/src/MuonCSCDetLayerGeometryBuilder.h>
00016 #include <RecoMuon/DetLayers/src/MuonRPCDetLayerGeometryBuilder.h>
00017 #include <RecoMuon/DetLayers/src/MuonDTDetLayerGeometryBuilder.h>
00018 
00019 #include <FWCore/Framework/interface/EventSetup.h>
00020 #include <FWCore/Framework/interface/ESHandle.h>
00021 
00022 #include <FWCore/MessageLogger/interface/MessageLogger.h>
00023 #include <FWCore/Framework/interface/NoProxyException.h>
00024 
00025 #include <memory>
00026 
00027 using namespace edm;
00028 
00029 MuonDetLayerGeometryESProducer::MuonDetLayerGeometryESProducer(const edm::ParameterSet & p){
00030   setWhatProduced(this);
00031 }
00032 
00033 
00034 MuonDetLayerGeometryESProducer::~MuonDetLayerGeometryESProducer(){}
00035 
00036 
00037 boost::shared_ptr<MuonDetLayerGeometry>
00038 MuonDetLayerGeometryESProducer::produce(const MuonRecoGeometryRecord & record) {
00039 
00040   const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuonDetLayerGeometryESProducer";
00041   MuonDetLayerGeometry* muonDetLayerGeometry = new MuonDetLayerGeometry();
00042   
00043   // Build DT layers  
00044   try {
00045     edm::ESHandle<DTGeometry> dt;
00046     record.getRecord<MuonGeometryRecord>().get(dt);
00047     if (dt.isValid()) {
00048       muonDetLayerGeometry->addDTLayers(MuonDTDetLayerGeometryBuilder::buildLayers(*dt));
00049     }
00050   } catch (edm::eventsetup::NoProxyException<DTGeometry>& e) {
00051     // No DT geo available: trap the exception.
00052     LogInfo(metname) << "No DT geometry is available."; 
00053   }
00054 
00055   // Build CSC layers
00056   try {
00057     edm::ESHandle<CSCGeometry> csc;
00058     record.getRecord<MuonGeometryRecord>().get(csc);
00059     if (csc.isValid()) {
00060       muonDetLayerGeometry->addCSCLayers(MuonCSCDetLayerGeometryBuilder::buildLayers(*csc));
00061     }
00062   } catch (edm::eventsetup::NoProxyException<CSCGeometry>& e) {
00063     // No CSC geo available: trap the exception.
00064     LogInfo(metname) << "No CSC geometry is available.";
00065   }
00066   
00067   // Build RPC layers
00068   try {
00069     edm::ESHandle<RPCGeometry> rpc;
00070     record.getRecord<MuonGeometryRecord>().get(rpc);
00071     if (rpc.isValid()) {
00072       muonDetLayerGeometry->addRPCLayers(MuonRPCDetLayerGeometryBuilder::buildBarrelLayers(*rpc),MuonRPCDetLayerGeometryBuilder::buildEndcapLayers(*rpc));
00073     }
00074     
00075   } catch (edm::eventsetup::NoProxyException<RPCGeometry>& e) {
00076     // No RPC geo available: trap the exception.
00077     LogInfo(metname) << "No RPC geometry is available.";
00078   }  
00079   
00080 
00081   // Sort layers properly
00082   muonDetLayerGeometry->sortLayers();
00083 
00084   return boost::shared_ptr<MuonDetLayerGeometry>(muonDetLayerGeometry);
00085 }