Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:31:44

0001 // -*- C++ -*-
0002 //
0003 // Package:    DetIdAssociatorESProducer
0004 // Class:      DetIdAssociatorESProducer
0005 //
0006 /**\class DetIdAssociatorESProducer TrackingTools/TrackAssociator/plugins/DetIdAssociatorESProducer.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Jean-Roch Vlimant
0015 //         Created:  Thu Oct  4 02:28:48 CEST 2007
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 
0022 // user include files
0023 #include "FWCore/Framework/interface/ModuleFactory.h"
0024 #include "FWCore/Framework/interface/ESProducer.h"
0025 
0026 #include "TrackingTools/TrackAssociator/interface/DetIdAssociator.h"
0027 #include "DetIdAssociatorFactory.h"
0028 #include "DetIdAssociatorMaker.h"
0029 
0030 #include "TrackingTools/Records/interface/DetIdAssociatorRecord.h"
0031 
0032 //
0033 // class decleration
0034 //
0035 
0036 class DetIdAssociatorESProducer : public edm::ESProducer {
0037 public:
0038   DetIdAssociatorESProducer(const edm::ParameterSet&);
0039   ~DetIdAssociatorESProducer() override;
0040 
0041   typedef std::unique_ptr<DetIdAssociator> ReturnType;
0042 
0043   ReturnType produce(const DetIdAssociatorRecord&);
0044 
0045 private:
0046   const std::string cName;
0047   std::unique_ptr<const DetIdAssociatorMaker> maker_;
0048 };
0049 
0050 //
0051 // constants, enums and typedefs
0052 //
0053 
0054 //
0055 // static data member definitions
0056 //
0057 
0058 //
0059 // constructors and destructor
0060 //
0061 DetIdAssociatorESProducer::DetIdAssociatorESProducer(const edm::ParameterSet& iConfig)
0062     : cName{iConfig.getParameter<std::string>("ComponentName")},
0063       maker_{DetIdAssociatorFactory::get()->create(cName, iConfig, setWhatProduced(this, cName))} {}
0064 
0065 DetIdAssociatorESProducer::~DetIdAssociatorESProducer() {}
0066 
0067 //
0068 // member functions
0069 //
0070 
0071 // ------------ method called to produce the data  ------------
0072 DetIdAssociatorESProducer::ReturnType DetIdAssociatorESProducer::produce(const DetIdAssociatorRecord& iRecord) {
0073   using namespace edm::es;
0074   LogTrace("TrackAssociator") << "Making DetIdAssociatorRecord with label: " << cName;
0075   ReturnType dia = maker_->make(iRecord);
0076   dia->buildMap();
0077   LogTrace("TrackAssociator") << "Map id built for DetIdAssociatorRecord with label: " << cName;
0078   return dia;
0079 }
0080 
0081 //define this as a plug-in
0082 DEFINE_FWK_EVENTSETUP_MODULE(DetIdAssociatorESProducer);