Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:14:41

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