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  virtual ~AbsFFTJetRcdMapper() {}
23 
24  virtual void load(const edm::EventSetup& iSetup, edm::ESHandle<DataType>& handle) const = 0;
25 
26  virtual void load(const edm::EventSetup& iSetup, const std::string& label, edm::ESHandle<DataType>& handle) const = 0;
27 };
28 
29 template <class DataType, class RecordType>
30 struct ConcreteFFTJetRcdMapper : public AbsFFTJetRcdMapper<DataType> {
32 
33  inline void load(const edm::EventSetup& iSetup, edm::ESHandle<DataType>& handle) const override {
34  iSetup.get<RecordType>().get(handle);
35  }
36 
37  inline void load(const edm::EventSetup& iSetup,
38  const std::string& label,
39  edm::ESHandle<DataType>& handle) const override {
40  iSetup.get<RecordType>().get(label, handle);
41  }
42 };
43 
44 template <class DataType>
45 struct DefaultFFTJetRcdMapper : public std::map<std::string, AbsFFTJetRcdMapper<DataType>*> {
47 
49 
51  for (typename std::map<std::string, AbsFFTJetRcdMapper<DataType>*>::iterator it = this->begin(); it != this->end();
52  ++it)
53  delete it->second;
54  }
55 
56  inline void load(const edm::EventSetup& iSetup, const std::string& record, edm::ESHandle<DataType>& handle) const {
57  typename std::map<std::string, AbsFFTJetRcdMapper<DataType>*>::const_iterator it = this->find(record);
58  if (it == this->end())
59  throw cms::Exception("KeyNotFound") << "Record \"" << record << "\" is not registered\n";
60  it->second->load(iSetup, handle);
61  }
62 
63  inline void load(const edm::EventSetup& iSetup,
64  const std::string& record,
65  const std::string& label,
67  typename std::map<std::string, AbsFFTJetRcdMapper<DataType>*>::const_iterator it = this->find(record);
68  if (it == this->end())
69  throw cms::Exception("KeyNotFound") << "Record \"" << record << "\" is not registered\n";
70  it->second->load(iSetup, label, handle);
71  }
72 
75 };
76 
77 //
78 // Singleton for the mapper
79 //
80 template <class Mapper>
82 public:
84 
85  static const Mapper& instance() {
86  static Mapper obj;
87  return obj;
88  }
89 
90  template <class Record>
91  static void registerRecord(const std::string& record) {
92  Mapper& rd = const_cast<Mapper&>(instance());
93  delete rd[record];
95  }
96 
97  StaticFFTJetRcdMapper() = delete;
98 };
99 
100 #endif // JetMETCorrections_FFTJetObjects_FFTJetRcdMapper_h
DefaultFFTJetRcdMapper::load
void load(const edm::EventSetup &iSetup, const std::string &record, const std::string &label, edm::ESHandle< DataType > &handle) const
Definition: FFTJetRcdMapper.h:63
StaticFFTJetRcdMapper::registerRecord
static void registerRecord(const std::string &record)
Definition: FFTJetRcdMapper.h:91
ESHandle.h
patZpeak.handle
handle
Definition: patZpeak.py:23
AbsFFTJetRcdMapper::~AbsFFTJetRcdMapper
virtual ~AbsFFTJetRcdMapper()
Definition: FFTJetRcdMapper.h:22
DefaultFFTJetRcdMapper::load
void load(const edm::EventSetup &iSetup, const std::string &record, edm::ESHandle< DataType > &handle) const
Definition: FFTJetRcdMapper.h:56
DefaultFFTJetRcdMapper::operator=
DefaultFFTJetRcdMapper & operator=(const DefaultFFTJetRcdMapper &)=delete
DefaultFFTJetRcdMapper::data_type
DataType data_type
Definition: FFTJetRcdMapper.h:46
StaticFFTJetRcdMapper::StaticFFTJetRcdMapper
StaticFFTJetRcdMapper()=delete
DefaultFFTJetRcdMapper::DefaultFFTJetRcdMapper
DefaultFFTJetRcdMapper()
Definition: FFTJetRcdMapper.h:48
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
Mapper
Definition: DDLMap.cc:41
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
StaticFFTJetRcdMapper
Definition: FFTJetRcdMapper.h:81
mps_fire.end
end
Definition: mps_fire.py:242
ConcreteFFTJetRcdMapper
Definition: FFTJetRcdMapper.h:30
edm::ESHandle
Definition: DTSurvey.h:22
ConcreteFFTJetRcdMapper::load
void load(const edm::EventSetup &iSetup, const std::string &label, edm::ESHandle< DataType > &handle) const override
Definition: FFTJetRcdMapper.h:37
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
DefaultFFTJetRcdMapper::~DefaultFFTJetRcdMapper
virtual ~DefaultFFTJetRcdMapper()
Definition: FFTJetRcdMapper.h:50
StaticFFTJetRcdMapper::instance
static const Mapper & instance()
Definition: FFTJetRcdMapper.h:85
ecal::multifit::data_type
::ecal::reco::ComputationScalarType data_type
Definition: EigenMatrixTypes_gpu.h:18
StaticFFTJetRcdMapper::data_type
Mapper::Base::data_type data_type
Definition: FFTJetRcdMapper.h:83
edm::EventSetup
Definition: EventSetup.h:58
AlCaHarvesting_cff.record
record
Definition: AlCaHarvesting_cff.py:42
ConcreteFFTJetRcdMapper::~ConcreteFFTJetRcdMapper
~ConcreteFFTJetRcdMapper() override
Definition: FFTJetRcdMapper.h:31
get
#define get
DefaultFFTJetRcdMapper
Definition: FFTJetRcdMapper.h:45
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
std
Definition: JetResolutionObject.h:76
ConcreteFFTJetRcdMapper::load
void load(const edm::EventSetup &iSetup, edm::ESHandle< DataType > &handle) const override
Definition: FFTJetRcdMapper.h:33
Exception
Definition: hltDiff.cc:245
AbsFFTJetRcdMapper
Definition: FFTJetRcdMapper.h:21
EventSetup.h
Exception.h
genParticles_cff.map
map
Definition: genParticles_cff.py:11
label
const char * label
Definition: PFTauDecayModeTools.cc:11
AbsFFTJetRcdMapper::load
virtual void load(const edm::EventSetup &iSetup, edm::ESHandle< DataType > &handle) const =0
HLT_FULL_cff.DataType
DataType
Definition: HLT_FULL_cff.py:32781