File indexing completed on 2024-04-06 12:29:39
0001 #ifndef SimDataFormats_Associations_MtdRecoClusterToSimLayerClusterAssociationMap_h
0002 #define SimDataFormats_Associations_MtdRecoClusterToSimLayerClusterAssociationMap_h
0003
0004 #include "DataFormats/Provenance/interface/ProductID.h"
0005 #include "DataFormats/Common/interface/HandleBase.h"
0006 #include "DataFormats/FTLRecHit/interface/FTLClusterCollections.h"
0007 #include "SimDataFormats/CaloAnalysis/interface/MtdSimLayerClusterFwd.h"
0008
0009 #include <vector>
0010 #include <utility>
0011 #include <algorithm>
0012
0013
0014
0015
0016
0017 class MtdRecoClusterToSimLayerClusterAssociationMap {
0018 public:
0019 using key_type = FTLClusterRef;
0020 using mapped_type = MtdSimLayerClusterRef;
0021 using value_type = std::pair<key_type, std::vector<mapped_type>>;
0022 using map_type = std::vector<value_type>;
0023 using const_iterator = typename map_type::const_iterator;
0024 using range = std::pair<const_iterator, const_iterator>;
0025
0026
0027 MtdRecoClusterToSimLayerClusterAssociationMap();
0028
0029 ~MtdRecoClusterToSimLayerClusterAssociationMap();
0030
0031 void emplace_back(const FTLClusterRef& recoClus, std::vector<MtdSimLayerClusterRef>& simClusVect) {
0032 map_.emplace_back(recoClus, simClusVect);
0033 }
0034
0035 void post_insert() { std::sort(map_.begin(), map_.end(), compare); }
0036
0037 bool empty() const { return map_.empty(); }
0038 size_t size() const { return map_.size(); }
0039
0040 const_iterator begin() const { return map_.begin(); }
0041 const_iterator cbegin() const { return map_.cbegin(); }
0042 const_iterator end() const { return map_.end(); }
0043 const_iterator cend() const { return map_.cend(); }
0044
0045 range equal_range(const FTLClusterRef& key) const {
0046 return std::equal_range(map_.begin(), map_.end(), value_type(key, std::vector<MtdSimLayerClusterRef>()), compare);
0047 }
0048
0049 const map_type& map() const { return map_; }
0050
0051 private:
0052 static bool compare(const value_type& i, const value_type& j) { return (i.first < j.first); }
0053
0054 map_type map_;
0055 };
0056
0057 #endif