File indexing completed on 2024-04-06 12:24:37
0001 #ifndef RecoBTau_JetTagComputerESProducer_h
0002 #define RecoBTau_JetTagComputerESProducer_h
0003
0004 #include <string>
0005 #include <memory>
0006 #include <type_traits>
0007
0008 #include "FWCore/Framework/interface/ESProducer.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 #include "RecoBTau/JetTagComputer/interface/JetTagComputerRecord.h"
0011 #include "RecoBTau/JetTagComputer/interface/JetTagComputer.h"
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 namespace jet_tag_computer_esproducer_impl {
0030 template <typename ConcreteJetTagComputer, bool>
0031 class JetTagComputerESProducer : public edm::ESProducer {
0032 private:
0033
0034 static_assert(std::is_convertible_v<ConcreteJetTagComputer*, JetTagComputer*>);
0035
0036 public:
0037 using Tokens = typename ConcreteJetTagComputer::Tokens;
0038
0039 JetTagComputerESProducer(const edm::ParameterSet& pset)
0040 : m_tokens(pset, setWhatProduced(this, pset.getParameter<std::string>("@module_label"))), m_pset(pset) {}
0041
0042 std::unique_ptr<JetTagComputer> produce(const JetTagComputerRecord& record) {
0043 std::unique_ptr<JetTagComputer> jetTagComputer = std::make_unique<ConcreteJetTagComputer>(m_pset, m_tokens);
0044 jetTagComputer->initialize(record);
0045 jetTagComputer->setupDone();
0046 return jetTagComputer;
0047 }
0048
0049 private:
0050 const Tokens m_tokens;
0051 const edm::ParameterSet m_pset;
0052 };
0053
0054 template <typename ConcreteJetTagComputer>
0055 class JetTagComputerESProducer<ConcreteJetTagComputer, true> : public edm::ESProducer {
0056 private:
0057
0058 static_assert(std::is_convertible_v<ConcreteJetTagComputer*, JetTagComputer*>);
0059
0060 public:
0061 JetTagComputerESProducer(const edm::ParameterSet& pset) : m_pset(pset) {
0062 setWhatProduced(this, pset.getParameter<std::string>("@module_label"));
0063 }
0064
0065 std::unique_ptr<JetTagComputer> produce(const JetTagComputerRecord& record) {
0066 std::unique_ptr<JetTagComputer> jetTagComputer = std::make_unique<ConcreteJetTagComputer>(m_pset);
0067 jetTagComputer->initialize(record);
0068 jetTagComputer->setupDone();
0069 return jetTagComputer;
0070 }
0071
0072 private:
0073 const edm::ParameterSet m_pset;
0074 };
0075 }
0076
0077 template <typename T>
0078 using JetTagComputerESProducer =
0079 jet_tag_computer_esproducer_impl::JetTagComputerESProducer<T, std::is_same_v<typename T::Tokens, void>>;
0080
0081 #endif