CMS 3D CMS Logo

FFTJetRcdMapper.h
Go to the documentation of this file.
1 #ifndef JetMETCorrections_FFTJetObjects_FFTJetRcdMapper_h
2 #define JetMETCorrections_FFTJetObjects_FFTJetRcdMapper_h
3 
4 //
5 // A factory to combat the proliferation of ES record types
6 // (multiple record types are necessary due to deficiencies
7 // in the record dependency tracking mechanism). Templated
8 // upon the data type which records hold.
9 //
10 // Igor Volobouev
11 // 08/03/2012
12 
13 #include <map>
14 #include <string>
15 
19 
20 template<class DataType>
22 {
23  virtual ~AbsFFTJetRcdMapper() {}
24 
25  virtual void load(const edm::EventSetup& iSetup,
26  edm::ESHandle<DataType>& handle) const = 0;
27 
28  virtual void load(const edm::EventSetup& iSetup,
29  const std::string& label,
30  edm::ESHandle<DataType>& handle) const = 0;
31 };
32 
33 template<class DataType, class RecordType>
35 {
37 
38  inline void load(const edm::EventSetup& iSetup,
39  edm::ESHandle<DataType>& handle) const override
40  {iSetup.get<RecordType>().get(handle);}
41 
42  inline void load(const edm::EventSetup& iSetup,
43  const std::string& label,
44  edm::ESHandle<DataType>& handle) const override
45  {iSetup.get<RecordType>().get(label, handle);}
46 };
47 
48 template<class DataType>
50  public std::map<std::string, AbsFFTJetRcdMapper<DataType>*>
51 {
53 
56 
58  {
60  iterator it = this->begin(); it != this->end(); ++it)
61  delete it->second;
62  }
63 
64  inline void load(const edm::EventSetup& iSetup,
65  const std::string& record,
67  {
68  typename std::map<std::string, AbsFFTJetRcdMapper<DataType>*>::
69  const_iterator it = this->find(record);
70  if (it == this->end())
71  throw cms::Exception("KeyNotFound")
72  << "Record \"" << record << "\" is not registered\n";
73  it->second->load(iSetup, handle);
74  }
75 
76  inline void load(const edm::EventSetup& iSetup,
77  const std::string& record,
78  const std::string& label,
80  {
81  typename std::map<std::string, AbsFFTJetRcdMapper<DataType>*>::
82  const_iterator it = this->find(record);
83  if (it == this->end())
84  throw cms::Exception("KeyNotFound")
85  << "Record \"" << record << "\" is not registered\n";
86  it->second->load(iSetup, label, handle);
87  }
88 
89 private:
91  DefaultFFTJetRcdMapper& operator=(const DefaultFFTJetRcdMapper&) = delete;
92 };
93 
94 //
95 // Singleton for the mapper
96 //
97 template <class Mapper>
99 {
100 public:
101  typedef typename Mapper::Base::data_type data_type;
102 
103  static const Mapper& instance()
104  {
105  static Mapper obj;
106  return obj;
107  }
108 
109  template <class Record>
110  static void registerRecord(const std::string& record)
111  {
112  Mapper& rd = const_cast<Mapper&>(instance());
113  delete rd[record];
115  }
116 
117 private:
118  StaticFFTJetRcdMapper() = delete;
119 };
120 
121 #endif // JetMETCorrections_FFTJetObjects_FFTJetRcdMapper_h
JetCorrectorParameters::Record record
Definition: classes.h:7
static PFTauRenderPlugin instance
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
virtual ~DefaultFFTJetRcdMapper()
void load(const edm::EventSetup &iSetup, const std::string &label, edm::ESHandle< DataType > &handle) const override
char const * label
static void registerRecord(const std::string &record)
virtual void load(const edm::EventSetup &iSetup, edm::ESHandle< DataType > &handle) const =0
Mapper::Base::data_type data_type
#define end
Definition: vmac.h:39
Definition: DDLMap.cc:38
virtual ~AbsFFTJetRcdMapper()
void load(const edm::EventSetup &iSetup, const std::string &record, edm::ESHandle< DataType > &handle) const
void load(const edm::EventSetup &iSetup, edm::ESHandle< DataType > &handle) const override
#define begin
Definition: vmac.h:32
T get() const
Definition: EventSetup.h:68
~ConcreteFFTJetRcdMapper() override
static const Mapper & instance()
void load(const edm::EventSetup &iSetup, const std::string &record, const std::string &label, edm::ESHandle< DataType > &handle) const