Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:35

0001 #include "TrackingTools/RecoGeometry/plugins/GlobalDetLayerGeometryESProducer.h"
0002 
0003 #include "FWCore/Framework/interface/EventSetup.h"
0004 #include "FWCore/Framework/interface/ESHandle.h"
0005 #include "FWCore/Framework/interface/ModuleFactory.h"
0006 #include "FWCore/Framework/interface/ESProducer.h"
0007 
0008 #include <memory>
0009 #include <string>
0010 
0011 using namespace edm;
0012 
0013 GlobalDetLayerGeometryESProducer::GlobalDetLayerGeometryESProducer(const edm::ParameterSet& p) {
0014   std::string myName = p.getParameter<std::string>("ComponentName");
0015   auto cc = setWhatProduced(this, myName);
0016   trackerToken_ = cc.consumes();
0017   muonToken_ = cc.consumes();
0018   mtdToken_ = cc.consumes();
0019 }
0020 
0021 GlobalDetLayerGeometryESProducer::~GlobalDetLayerGeometryESProducer() {}
0022 
0023 std::unique_ptr<DetLayerGeometry> GlobalDetLayerGeometryESProducer::produce(const RecoGeometryRecord& iRecord) {
0024   auto const& tracker = iRecord.get(trackerToken_);
0025   auto const& muon = iRecord.get(muonToken_);
0026   edm::ESHandle<MTDDetLayerGeometry> mtd;
0027 
0028   // get the MTD if it is available
0029   if (auto mtdRecord = iRecord.tryToGetRecord<MTDRecoGeometryRecord>()) {
0030     mtd = mtdRecord->getHandle(mtdToken_);
0031     if (!mtd.isValid()) {
0032       LogInfo("GlobalDetLayergGeometryBuilder") << "No MTD geometry is available.";
0033     }
0034   } else {
0035     LogInfo("GlobalDetLayerGeometryBuilder") << "No MTDRecoGeometryRecord is available.";
0036   }
0037 
0038   // if we've got MTD initialize it
0039   if (mtd.isValid())
0040     return std::make_unique<GlobalDetLayerGeometry>(&tracker, &muon, mtd.product());
0041 
0042   return std::make_unique<GlobalDetLayerGeometry>(&tracker, &muon);
0043 }
0044 
0045 DEFINE_FWK_EVENTSETUP_MODULE(GlobalDetLayerGeometryESProducer);