File indexing completed on 2024-04-06 12:19:17
0001 #ifndef JetMETCorrections_FFTJetObjects_FFTJetDict_h
0002 #define JetMETCorrections_FFTJetObjects_FFTJetDict_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include <map>
0013 #include "FWCore/Utilities/interface/Exception.h"
0014
0015 template <class Key, class T, class Compare = std::less<Key>, class Allocator = std::allocator<std::pair<const Key, T> > >
0016 struct FFTJetDict : public std::map<Key, T, Compare, Allocator> {
0017 inline T& operator[](const Key&);
0018 inline const T& operator[](const Key&) const;
0019 };
0020
0021 template <class Key, class T, class Compare, class Allocator>
0022 T& FFTJetDict<Key, T, Compare, Allocator>::operator[](const Key& key) {
0023 typename FFTJetDict<Key, T, Compare, Allocator>::const_iterator it = this->find(key);
0024 if (it == std::map<Key, T, Compare, Allocator>::end())
0025 throw cms::Exception("KeyNotFound") << "FFTJetDict: key \"" << key << "\" not found\n";
0026 return const_cast<T&>(it->second);
0027 }
0028
0029 template <class Key, class T, class Compare, class Allocator>
0030 const T& FFTJetDict<Key, T, Compare, Allocator>::operator[](const Key& key) const {
0031 typename FFTJetDict<Key, T, Compare, Allocator>::const_iterator it = this->find(key);
0032 if (it == std::map<Key, T, Compare, Allocator>::end())
0033 throw cms::Exception("KeyNotFound") << "FFTJetDict: key \"" << key << "\" not found\n";
0034 return it->second;
0035 }
0036 #endif