Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:52:57

0001 #ifndef DataFormats_Common_DetSet2RangeMap_h
0002 #define DataFormats_Common_DetSet2RangeMap_h
0003 
0004 #include "DataFormats/Common/interface/DetSetVectorNew.h"
0005 #include "DataFormats/Common/interface/RangeMap.h"
0006 // #include "DataFormats/Common/interface/DetSetAlgorithm.h"
0007 
0008 #include <algorithm>
0009 
0010 //FIXME remove New when ready
0011 namespace edmNew {
0012 
0013   namespace dstvdetails {
0014     // copy from DS to RM
0015     template <typename B>
0016     struct ToRM {
0017       ToRM(edm::RangeMap<det_id_type, edm::OwnVector<B> >& irm) : rm(&irm) {}
0018       edm::RangeMap<det_id_type, edm::OwnVector<B> >* rm;
0019       template <typename T>
0020       void operator()(edmNew::DetSet<T> const& ds) {
0021         // make it easy
0022         // std::vector<T const *> v(ds.size());
0023         //std::transform(ds.begin(),ds.end(),v.begin(),dstvdetails::Pointer());
0024         if (!ds.empty())
0025           rm->put(ds.id(), ds.begin(), ds.end());
0026       }
0027     };
0028   }  // namespace dstvdetails
0029 
0030   // copy from DSTV to RangeMap
0031   template <typename T, typename B>
0032   void copy(DetSetVector<T> const& dstv, edm::RangeMap<det_id_type, edm::OwnVector<B> >& rm) {
0033     dstvdetails::ToRM<B> torm(rm);
0034     std::for_each(dstv.begin(), dstv.end(), torm);
0035   }
0036 
0037 }  // namespace edmNew
0038 
0039 #endif  // DataFormats_Common_DetSet2RangeMap_h