Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-04-12 23:30:30

0001 /** \file
0002  *
0003  *  ESProducer for MTDDetLayerGeometry in RecoMTD/DetLayers
0004  *
0005  *  \author L. Gray - FNAL
0006  *
0007  */
0008 
0009 #include "FWCore/Framework/interface/ESProducer.h"
0010 #include "FWCore/Framework/interface/ModuleFactory.h"
0011 #include "FWCore/Framework/interface/EventSetup.h"
0012 #include "FWCore/Framework/interface/ESHandle.h"
0013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0014 
0015 #include "RecoMTD/Records/interface/MTDRecoGeometryRecord.h"
0016 #include "Geometry/Records/interface/MTDDigiGeometryRecord.h"
0017 #include "Geometry/MTDGeometryBuilder/interface/MTDGeometry.h"
0018 #include "Geometry/Records/interface/MTDTopologyRcd.h"
0019 #include "Geometry/MTDNumberingBuilder/interface/MTDTopology.h"
0020 
0021 #include "RecoMTD/DetLayers/interface/ETLDetLayerGeometryBuilder.h"
0022 #include "RecoMTD/DetLayers/interface/BTLDetLayerGeometryBuilder.h"
0023 #include "RecoMTD/DetLayers/interface/MTDDetLayerGeometry.h"
0024 
0025 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0026 
0027 #include <memory>
0028 #include <iostream>
0029 
0030 class MTDDetLayerGeometryESProducer : public edm::ESProducer {
0031 public:
0032   /// Constructor
0033   MTDDetLayerGeometryESProducer(const edm::ParameterSet& p);
0034 
0035   /// Produce MuonDeLayerGeometry.
0036   std::unique_ptr<MTDDetLayerGeometry> produce(const MTDRecoGeometryRecord& record);
0037 
0038   static void fillDescriptions(edm::ConfigurationDescriptions&);
0039 
0040 private:
0041   edm::ESGetToken<MTDGeometry, MTDDigiGeometryRecord> geomToken_;
0042   edm::ESGetToken<MTDTopology, MTDTopologyRcd> mtdtopoToken_;
0043 };
0044 
0045 using namespace edm;
0046 
0047 MTDDetLayerGeometryESProducer::MTDDetLayerGeometryESProducer(const edm::ParameterSet& p) {
0048   auto cc = setWhatProduced(this);
0049   geomToken_ = cc.consumes();
0050   mtdtopoToken_ = cc.consumes();
0051 }
0052 
0053 std::unique_ptr<MTDDetLayerGeometry> MTDDetLayerGeometryESProducer::produce(const MTDRecoGeometryRecord& record) {
0054   auto mtdDetLayerGeometry = std::make_unique<MTDDetLayerGeometry>();
0055   auto mtd = record.getHandle(geomToken_);
0056   auto mtdtopo = record.getHandle(mtdtopoToken_);
0057 
0058   //The BTL and ETL builders are now called internally by the MTDDetLayerGeometry.
0059   //This allows external plugings to use and build the object.
0060   mtdDetLayerGeometry->buildLayers(&(*mtd), &(*mtdtopo));
0061 
0062   // Sort layers properly
0063   mtdDetLayerGeometry->sortLayers();
0064 
0065   return mtdDetLayerGeometry;
0066 }
0067 
0068 void MTDDetLayerGeometryESProducer::fillDescriptions(edm::ConfigurationDescriptions& desc) {
0069   edm::ParameterSetDescription ps;
0070   desc.addDefault(ps);
0071 }
0072 
0073 DEFINE_FWK_EVENTSETUP_MODULE(MTDDetLayerGeometryESProducer);