Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:27:50

0001 #include <FWCore/Utilities/interface/ESInputTag.h>
0002 
0003 #include <memory>
0004 
0005 // user include files
0006 #include "FWCore/Framework/interface/ModuleFactory.h"
0007 #include "FWCore/Framework/interface/ESProducer.h"
0008 
0009 #include "FWCore/Framework/interface/ESHandle.h"
0010 #include "FWCore/Utilities/interface/Visibility.h"
0011 
0012 #include "NavigationSchoolFactory.h"
0013 #include "RecoTracker/Record/interface/NavigationSchoolRecord.h"
0014 
0015 //
0016 // class decleration
0017 //
0018 
0019 class dso_hidden NavigationSchoolESProducer final : public edm::ESProducer {
0020 public:
0021   NavigationSchoolESProducer(const edm::ParameterSet&);
0022 
0023   typedef std::unique_ptr<NavigationSchool> ReturnType;
0024 
0025   virtual ReturnType produce(const NavigationSchoolRecord&);
0026 
0027   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0028 
0029 private:
0030   // ----------member data ---------------------------
0031   edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magFieldToken_;
0032   edm::ESGetToken<GeometricSearchTracker, TrackerRecoGeometryRecord> geometricSearchTrackerToken_;
0033   const std::string navigationSchoolName_;
0034 };
0035 
0036 //
0037 //
0038 // constructors and destructor
0039 //
0040 NavigationSchoolESProducer::NavigationSchoolESProducer(const edm::ParameterSet& iConfig)
0041     : navigationSchoolName_(iConfig.getParameter<std::string>("ComponentName")) {
0042   //the following line is needed to tell the framework what
0043   // data is being produced
0044 
0045   auto cc = setWhatProduced(this, navigationSchoolName_);
0046   magFieldToken_ = cc.consumes(edm::ESInputTag("", iConfig.getParameter<std::string>("SimpleMagneticField")));
0047   geometricSearchTrackerToken_ = cc.consumes();
0048 
0049   //now do what ever other initialization is needed
0050 }
0051 
0052 //
0053 // member functions
0054 //
0055 
0056 // ------------ method called to produce the data  ------------
0057 NavigationSchoolESProducer::ReturnType NavigationSchoolESProducer::produce(const NavigationSchoolRecord& iRecord) {
0058   using namespace edm::es;
0059 
0060   //get the geometricsearch tracker geometry
0061   return ReturnType(NavigationSchoolFactory::get()->create(
0062       navigationSchoolName_, &iRecord.get(geometricSearchTrackerToken_), &iRecord.get(magFieldToken_)));
0063 }
0064 
0065 void NavigationSchoolESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0066   edm::ParameterSetDescription desc;
0067   desc.add<std::string>("ComponentName");
0068   desc.add<std::string>("SimpleMagneticField", "");
0069   descriptions.addDefault(desc);
0070 }
0071 
0072 #include "FWCore/PluginManager/interface/ModuleDef.h"
0073 #include "FWCore/Framework/interface/MakerMacros.h"
0074 DEFINE_FWK_EVENTSETUP_MODULE(NavigationSchoolESProducer);