Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:08:11

0001 /** \file GlobalTrackingGeometryESProducer.cc
0002  *
0003  *  \author Matteo Sani
0004  */
0005 
0006 #include "Geometry/GlobalTrackingGeometryBuilder/plugins/GlobalTrackingGeometryESProducer.h"
0007 #include "Geometry/GlobalTrackingGeometryBuilder/plugins/GlobalTrackingGeometryBuilder.h"
0008 #include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
0009 
0010 #include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"
0011 
0012 #include "FWCore/Framework/interface/ESHandle.h"
0013 #include "FWCore/Framework/interface/ModuleFactory.h"
0014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0015 #include "FWCore/Framework/interface/NoProxyException.h"
0016 #include "FWCore/Framework/interface/NoRecordException.h"
0017 
0018 #include <memory>
0019 
0020 using namespace edm;
0021 
0022 GlobalTrackingGeometryESProducer::GlobalTrackingGeometryESProducer(const edm::ParameterSet& p) {
0023   auto cc = setWhatProduced(this);
0024   trackerToken_ = cc.consumesFrom<TrackerGeometry, TrackerDigiGeometryRecord>(edm::ESInputTag{});
0025   mtdToken_ = cc.consumesFrom<MTDGeometry, MTDDigiGeometryRecord>(edm::ESInputTag{});
0026   dtToken_ = cc.consumesFrom<DTGeometry, MuonGeometryRecord>(edm::ESInputTag{});
0027   cscToken_ = cc.consumesFrom<CSCGeometry, MuonGeometryRecord>(edm::ESInputTag{});
0028   rpcToken_ = cc.consumesFrom<RPCGeometry, MuonGeometryRecord>(edm::ESInputTag{});
0029   gemToken_ = cc.consumesFrom<GEMGeometry, MuonGeometryRecord>(edm::ESInputTag{});
0030   me0Token_ = cc.consumesFrom<ME0Geometry, MuonGeometryRecord>(edm::ESInputTag{});
0031 }
0032 
0033 GlobalTrackingGeometryESProducer::~GlobalTrackingGeometryESProducer() {}
0034 
0035 std::unique_ptr<GlobalTrackingGeometry> GlobalTrackingGeometryESProducer::produce(
0036     const GlobalTrackingGeometryRecord& record) {
0037   TrackerGeometry const* tk = nullptr;
0038   MTDGeometry const* mtd = nullptr;
0039   DTGeometry const* dt = nullptr;
0040   CSCGeometry const* csc = nullptr;
0041   RPCGeometry const* rpc = nullptr;
0042   GEMGeometry const* gem = nullptr;
0043   ME0Geometry const* me0 = nullptr;
0044 
0045   if (auto tkRecord = record.tryToGetRecord<TrackerDigiGeometryRecord>()) {
0046     if (auto tkH = tkRecord->getHandle(trackerToken_)) {
0047       tk = tkH.product();
0048     } else {
0049       LogWarning("GeometryGlobalTrackingGeometryBuilder") << "No Tracker geometry is available.";
0050     }
0051   } else {
0052     LogWarning("GeometryGlobalTrackingGeometryBuilder") << "No TrackerDigiGeometryRecord is available.";
0053   }
0054 
0055   if (auto mtdRecord = record.tryToGetRecord<MTDDigiGeometryRecord>()) {
0056     if (auto mtdH = mtdRecord->getHandle(mtdToken_)) {
0057       mtd = mtdH.product();
0058     } else {
0059       LogInfo("GeometryGlobalTrackingGeometryBuilder") << "No MTD geometry is available.";
0060     }
0061   } else {
0062     LogInfo("GeometryGlobalTrackingGeometryBuilder") << "No MTDDigiGeometryRecord is available.";
0063   }
0064 
0065   if (auto muonRecord = record.tryToGetRecord<MuonGeometryRecord>()) {
0066     if (auto dtH = muonRecord->getHandle(dtToken_)) {
0067       dt = dtH.product();
0068     } else {
0069       LogWarning("GeometryGlobalTrackingGeometryBuilder") << "No DT geometry is available.";
0070     }
0071 
0072     if (auto cscH = muonRecord->getHandle(cscToken_)) {
0073       csc = cscH.product();
0074     } else {
0075       LogWarning("GeometryGlobalTrackingGeometryBuilder") << "No CSC geometry is available.";
0076     }
0077 
0078     if (auto rpcH = muonRecord->getHandle(rpcToken_)) {
0079       rpc = rpcH.product();
0080     } else {
0081       LogWarning("GeometryGlobalTrackingGeometryBuilder") << "No RPC geometry is available.";
0082     }
0083 
0084     if (auto gemH = muonRecord->getHandle(gemToken_)) {
0085       gem = gemH.product();
0086     } else {
0087       LogInfo("GeometryGlobalTrackingGeometryBuilder") << "No GEM geometry is available.";
0088     }
0089 
0090     if (auto me0H = muonRecord->getHandle(me0Token_)) {
0091       me0 = me0H.product();
0092     } else {
0093       LogInfo("GeometryGlobalTrackingGeometryBuilder") << "No ME0 geometry is available.";
0094     }
0095 
0096   } else {
0097     LogWarning("GeometryGlobalTrackingGeometryBuilder") << "No MuonGeometryRecord is available.";
0098   }
0099 
0100   GlobalTrackingGeometryBuilder builder;
0101   return std::unique_ptr<GlobalTrackingGeometry>(builder.build(tk, mtd, dt, csc, rpc, gem, me0));
0102 }
0103 
0104 DEFINE_FWK_EVENTSETUP_MODULE(GlobalTrackingGeometryESProducer);