File indexing completed on 2024-04-06 12:28:07
0001 #include "FWCore/Framework/interface/ModuleFactory.h"
0002 #include "FWCore/Framework/interface/ESProducer.h"
0003 #include "FWCore/Framework/interface/ESHandle.h"
0004
0005 #include "RecoTracker/FinalTrackSelectors/interface/TrackAlgoPriorityOrder.h"
0006
0007 #include "RecoTracker/Record/interface/CkfComponentsRecord.h"
0008
0009 class TrackAlgoPriorityOrderESProducer : public edm::ESProducer {
0010 public:
0011 TrackAlgoPriorityOrderESProducer(const edm::ParameterSet& iConfig);
0012 ~TrackAlgoPriorityOrderESProducer() override = default;
0013
0014 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0015
0016 std::unique_ptr<TrackAlgoPriorityOrder> produce(const CkfComponentsRecord& iRecord);
0017
0018 private:
0019 std::vector<reco::TrackBase::TrackAlgorithm> algoOrder_;
0020 };
0021
0022 TrackAlgoPriorityOrderESProducer::TrackAlgoPriorityOrderESProducer(const edm::ParameterSet& iConfig) {
0023 const auto& algoNames = iConfig.getParameter<std::vector<std::string> >("algoOrder");
0024 algoOrder_.reserve(algoNames.size());
0025 for (const auto& name : algoNames) {
0026 auto algo = reco::TrackBase::algoByName(name);
0027 if (algo == reco::TrackBase::undefAlgorithm && name != "undefAlgorithm") {
0028 throw cms::Exception("Configuration") << "Incorrect track algo " << name;
0029 }
0030 algoOrder_.push_back(algo);
0031 }
0032
0033 auto componentName = iConfig.getParameter<std::string>("ComponentName");
0034 setWhatProduced(this, componentName);
0035 }
0036
0037 void TrackAlgoPriorityOrderESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0038 edm::ParameterSetDescription desc;
0039 desc.add<std::string>("ComponentName", "trackAlgoPriorityOrder");
0040 desc.add<std::vector<std::string> >("algoOrder", std::vector<std::string>());
0041 descriptions.add("trackAlgoPriorityOrderDefault", desc);
0042 }
0043
0044 std::unique_ptr<TrackAlgoPriorityOrder> TrackAlgoPriorityOrderESProducer::produce(const CkfComponentsRecord& iRecord) {
0045 return std::make_unique<TrackAlgoPriorityOrder>(algoOrder_);
0046 }
0047
0048 #include "FWCore/PluginManager/interface/ModuleDef.h"
0049 #include "FWCore/Framework/interface/MakerMacros.h"
0050 DEFINE_FWK_EVENTSETUP_MODULE(TrackAlgoPriorityOrderESProducer);